How to chang matrix size 81x81x30 to 81x81x32 by add row

1 visualización (últimos 30 días)
nada
nada el 26 de En. de 2019
Comentada: Rik el 26 de En. de 2019
Hi all....
I have matrix size 81 x 81 x30 ( 3D )
i want to be 81 x 81 x 32
chang size matrix by add 2 row (zero number)
here the example in this file ( daily_avg_u.mat )

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 26 de En. de 2019
daily_avg_u(:,:,end + (1:2)) = zeros([size(daily_avg_u(:,:,1)),2]);
  1 comentario
Rik
Rik el 26 de En. de 2019
daily_avg_u(:,:,end + (1:2)) = 0;
works as well and might be clearer as to what is going on

Iniciar sesión para comentar.

Más respuestas (1)

Rik
Rik el 26 de En. de 2019
You can use the cat function to concatenate arrays in a specific dimension:
A=rand(81,81,30);
B=rand(81,81);
%or: B=zeros(size(A,1),size(A,2),1);
C=cat(3,A,B);

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by