Borrar filtros
Borrar filtros

How to plot cell arrays in a for loop?

2 visualizaciones (últimos 30 días)
Jose Peñaloza
Jose Peñaloza el 14 de Ag. de 2015
Comentada: dpb el 17 de Ag. de 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

Respuestas (1)

dpb
dpb el 14 de Ag. de 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 comentarios
Jose Peñaloza
Jose Peñaloza el 17 de Ag. de 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 el 17 de Ag. de 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).

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by