Extract entire matrices from a cell
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 28 de En. de 2020
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
el 28 de En. de 2020
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
el 28 de En. de 2020
Leave them in the struct. Use structfun() . Or use struct2cell() and cellfun()
AS
el 28 de En. de 2020
Respuestas (1)
Selva Karna
el 28 de En. de 2020
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
1 comentario
AS
el 28 de En. de 2020
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!