Extract entire matrices from a cell
이전 댓글 표시
Hallo,
I have a cell which contains 10 matrices. Each matrix contains data from a different sensor and all matrices have different number of rows although they have the same number of columns. I would like to extract the entire matrices from the cell and keep the name of each matrix.
Thanks in advance

댓글 수: 5
Walter Roberson
2020년 1월 28일
I would like to extract the entire matrices from the cell and keep the name of each matrix.
Does that imply that for the above you would like to get out variables named sensor_6436, snesor_11700, sensor_14808 and so on? If so then if the sensor names are constant then just write the various lines,
sensor_6436 = sensordata_all.sensor_6436;
sensor_11700 = sensordata_all.sensor_11700;
and so on.
If the sensor names are not constant... then Don't Do That.
Stephen23
2020년 1월 28일
AS's "Answer" moved here:
Thank you for fast response!
The name of the sensors are not constant and are changing while I am reading a *.csv file with all the data. From these data I have to find the sensor ID (in this case there are the number in the sensor names) and after normalize the time step in order all the sensors to have the same number of rows. As you can see now the data per each sensor has different number of rows (time) although they refer to the same time period.
Thanks again!
You state in your question that you "...have a cell which contains 10 matrices", but your screenshot clearly shows a scalar structure with ten fields:

What is stopping you from simply accessing the data from that structure?
Dynamically naming matrics is unlikely to be a good approach:
Walter Roberson
2020년 1월 28일
Leave them in the struct. Use structfun() . Or use struct2cell() and cellfun()
AS
2020년 1월 28일
답변 (1개)
Selva Karna
2020년 1월 28일
clc
clear all;
close all;
cel_len=length(your_cell);
for i=1:cel_len
exta_cel=your_cell(i);
ext_data(i)=ext_cel
end
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!