Organizing data into cells
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Adam
2017-2-14
编辑:Adam
2017-2-14
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!