Organizing data into cells

1 Ansicht (letzte 30 Tage)
Amy
Amy am 14 Feb. 2017
Kommentiert: Amy am 21 Feb. 2017
Introduction I have simulation results from 6 different simulations with the same variable names. Each separate simulation result was saved as .mat-file, and contained the same variable names.
From the 6 .mat files I have created a single cell that contains the variable names in the first column, and the data from the 6 different simulations in columns 2-7. (Using the commands: load, fieldnames and struct2cell)
Now, I would like to easily access the data to be able to analyze it, make graphs.
Question My idea is to convert the single big cell into many cells, where each new cell contains the data of one type of variable.
For example, row 1 of my big cell could be:
r(1,:)= 't' [1x6000 double] [1x3000 double] [1x1000 double] [1x2000 double] [1x1000 double] [1x1500 double]
Based on this row I would like to create a variable called 't', where
t=cell(6,1)
t(1,1)=r(1,2)
t(2,1)=r(1,3)
and so on.
The question is two-fold: 1) how can I do this? 2) is this the most handy way to organize my data?
I also came across the following tread that seems to be realted, but I don't understand how to apply it: http://nl.mathworks.com/matlabcentral/newsreader/view_thread/159440

Akzeptierte Antwort

Adam
Adam am 14 Feb. 2017
Bearbeitet: Adam am 14 Feb. 2017
When you load data from .mat files use the
S = load(...)
form instead, then you get a struct with your variables as field names. Then you can load the 2nd one as
S(2) = load(...);
assuming it has the same variables which will become fields again.
Then you can just access your data as e.g.
[ S.someField ]
or
[ S.( 'someVarName' ) ]
or
{ S.someField }
or
{ S.('someVarName') }
It depends on the format of the data as to how you access it
  1 Kommentar
Amy
Amy am 21 Feb. 2017
Thank you very much, it works!
I am now only struggling with dissimilar fieldnames in some cases.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Structures 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