Loading multiple datafile of different sizes

2 Ansichten (letzte 30 Tage)
Jason Smoker
Jason Smoker am 28 Mär. 2011
I have 30 measurement files that I would like to work with which are time dependent and not of equal length. I was wondering what the best way to load these in to plot them without dealing with each one individually. The 30 files are over a 6 day period and I want to plot them by day so they will not all be on one graph.
I started with a loop, but ran into trouble since the lengths of the files are not equal.
%%Load files
for I = 0:29
filename = sprintf('Tension&CBResistance_%i.lvm',I)
TCB(I+1,:,:) = load(filename);
end
If possible, I also rather not declare some huge 3D matrix just to pad the ends of data arrays with zeros or NaN.
Thanks:)

Antworten (1)

Oleg Komarov
Oleg Komarov am 28 Mär. 2011
Store them in a cell array or in a structure, if you can't concatenate.
for I = 0:29
filename = sprintf('Tension&CBResistance_%i.lvm',I)
TCB{I} = $load(filename);
TCB.(filename) = load(filename);
end
  1 Kommentar
Jason Smoker
Jason Smoker am 30 Mär. 2011
I'm not sure I understood all the code you introduced, but this seems to work for loading the files.
for I = 0:29
filename = sprintf('Tension&CBResistance_%i.lvm',I)
TCB{I+1} = load(filename);
end
Now my question becomes how to plot them all without listing each one.
If they were arrays, I could would do
plot(TCB(1:6,:,1), TCB(1:6,:,2))
but this doesn't seem to work for cells. I tried
plot(TCB{1:6}(:,1),TCB{1:6}(:,2))
but get a "??? Bad cell reference operation." error

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements 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