From cell array to matrix
Mostrar comentarios más antiguos
Hello! I have cell arrays, help me deal with the loop.
for i = 1:length(Animal)-1
Y=[X{i}];
end
data looks like this % X{1}=[0] X{2}=[0 1.2 1.4 1.6] X{3}=[0] X{4}=[0 1.3 1.5 1.6]....
My task is to create a 4x800 matrix, where if zero is the column [0 0 0 0], and the values will be in the column
Respuesta aceptada
Más respuestas (1)
Felix Albrecht
el 25 de Jul. de 2019
Try preallocating with zeros:
Y = zeros(4,800);
% Assuming that length(Animal)-1 = 800
for i = 1:length(Animal)-1
Y(:,i) = X{i};
end
2 comentarios
Andrei Bobrov
el 25 de Jul. de 2019
+1
Lev Mihailov
el 25 de Jul. de 2019
Editada: Lev Mihailov
el 25 de Jul. de 2019
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!