How to plot cell arrays in a for loop?
2 views (last 30 days)
Show older comments
I want to plot different graphs after load data from .wav or .avi files. The problem is because information is organized in cells that contains other cells. I tried to make different types of code but it didn't work, the last part is the plot code. So I hope you can help me This is my code:
files= dir('*.wav')
numfiles=length(files)
mydata= cell(numfiles,1);
info=cell(numfiles,1)
isFileSupported = true(numfiles, 1) ;
for j=1:numfiles
try
info{j}=mmfileinfo(files(j).name)
audio = info{j}.Audio
video = info{j}.Video;
catch ME
isFileSupported(j) = false;
continue;
end
end
supportedFiles = files(isFileSupported);
for k=1:numel(supportedFiles)
mydata{k}=importdata(supportedFiles(k).name);
end
for j=1:numfiles
H=mydata{k};
x={:}
y={:}
plot(x,y)
end
0 Comments
Answers (1)
dpb
on 14 Aug 2015
for k=1:numel(supportedFiles)
dat=importdata(supportedFiles(k).name);
figure % presume want a new figure for each file...
plot(dat(:,1), dat(:,2:end)) % presume 1st column is x, any others are to be plotted
end
2 Comments
dpb
on 17 Aug 2015
Use debugger and let us know what the result of numel(supportedFiles) and
which dat
after the importdata call. Needs must know what's you got; we have no data from which to work that lets us know what form any of the results are returned (or if any are, even).
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!