How to use reshape
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
anne d.
el 19 de Sept. de 2017
Respondida: Rik
el 19 de Sept. de 2017
Hi, I have a matrix m (x, y, z) with a size of 12x6x5. I would like to reshape the matrix having other z-values given in f (5x1 vector). I have written the reshape command like this: g=reshape(f, [m],3) This is the error message: Error using reshape. Size arguments must be integer scalars. I don't understand the error. Thanks for your help!
4 comentarios
Star Strider
el 19 de Sept. de 2017
It appears that ‘m’ is the (12x6x5) original matrix.
We need to know the desired result.
Respuesta aceptada
Rik
el 19 de Sept. de 2017
Assuming you want to change all 3rd dimension values to the vector f, this code should do what you want.
for n=1:length(f)
g(:,:,n)=f(n);
end
You can remove the loop by using repmat on the result of reshape(f,[1 1 5]) or permute(f,[2 3 1]).
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!