How to extend an array to a new dimension?
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sufayan Mulani
el 29 de Ag. de 2023
Respondida: Star Strider
el 29 de Ag. de 2023
Suppose, I have an array
a=rand(3, 4);
I want to create a new array 'b' which has [ 3, 4, 5] size, and all 2D matrix along the third dimension are equal to 'a'.
b = zeros([size(a) 5]);
for i=1:5
b(:, :, i) = a;
end
How can I do this using MATLAB functions.
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Ag. de 2023
a=rand(3, 4);
b = zeros([size(a) 5]);
for i=1:5
b(:, :, i) = a;
end
b
b2 = repmat(a, 1, 1, 5)
Both results are the same.
.
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!