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 comentarios

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
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!
Stephen23
Stephen23 el 28 de En. de 2020
Editada: Stephen23 el 28 de En. de 2020
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
Walter Roberson el 28 de En. de 2020
Leave them in the struct. Use structfun() . Or use struct2cell() and cellfun()
AS
AS el 28 de En. de 2020
You are write, its a structure and it is better to do al the calculations inside the structure.

Iniciar sesión para comentar.

Respuestas (1)

Selva Karna
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
AS el 28 de En. de 2020
Thanks for the answer. However this solution creates again the new structure ext_data with the same matrices.

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

AS
el 28 de En. de 2020

Comentada:

AS
el 28 de En. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by