cell to matrix
Mostrar comentarios más antiguos
I have a data set which is in a cell structure (<1x20>) I want to place all of the data into one matrix. As each of the data sets in this cell structure is of different size, such as the first one is: 61169x15 and the second is 59529x15 and so on... i'm trying to find a way of combining the cells into a matrix. I can do this manually by:
new_data=[data1;data2;data3;data4]
But i would like to run the same script for other data sets therefore am looking for a way of doing this in a loop. Is that possible? So, I was thinking of a loop which ran though the cells i.e. for i=1:size(data,2) %=1:20
and then applying the same process as above in the loop, but im not sure on how I would go about doing this.
thanks
1 comentario
Jan
el 4 de Nov. de 2011
Please by careful with the term "structure". It is often confused with "STRUCT" array.
Respuesta aceptada
Más respuestas (2)
Fangjun Jiang
el 3 de Nov. de 2011
If all cells have the same number of columns, would this help?
a{1}=rand(3,2);
a{2}=rand(4,2);
a{3}=rand(5,2);
cell2mat(a')
Ora Zyto
el 3 de Nov. de 2011
From your description, it seems like all of your data sets have the same number of columns, and varying number of rows. In your for loop, append your current dataset to your existing matrix:
for i=1:length(data),
new_data=[new_data;data{i}]
end
Ora
Categorías
Más información sobre Logical 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!