How to create multidimensional array from several vectors
Mostrar comentarios más antiguos
Hello,
I want to increase the performance of a program by vectorizing the code instead of using for-loops. For this I want to create a multidimensional array from several vectors. Below you can find a simplified example using for-loops.
%definition of vectors a,b,c,d
a=1:5;
b=6:10;
c=11:15;
d=16:20;
%creation of multidimensional array M
for u=1:5
M(:,:,u)=[a(u),b(u);c(u),d(u)]
end
I hope you can help me to find a solution for vectorizing this code. Thank you very much in advance!
1 comentario
Tobias Klenke
el 6 de Feb. de 2018
Respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements 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!