Filter löschen
Filter löschen

How to plot cell arrays in a for loop?

4 Ansichten (letzte 30 Tage)
Jose Peñaloza
Jose Peñaloza am 14 Aug. 2015
Kommentiert: dpb am 17 Aug. 2015
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

Antworten (1)

dpb
dpb am 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 Kommentare
Jose Peñaloza
Jose Peñaloza am 17 Aug. 2015
Hi!!! dpb I tried with your answer and the program showed me an error: ??? Error using ==> plot Not enough input arguments.
files= dir('*.avi')
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 k=1:numel(supportedFiles)
dat=importdata(supportedFiles(k).name);
figure
plot(dat(:,1), dat(:,2:end))
end
Thanks in advance :)
dpb
dpb am 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).

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by