3D matrix dimension change

dear sir/ma'am
I have a 3D matrix a(n:n:4) which is written as
a1=a(:,:,1);
a2=a(:,:,2);
a3=a(:,:,3);
a4=a:,:,4);
for t=1:n
a_matrix=[a1(t,t) a2(t,t);a3(t,t)a4(t,t)];
end
This code gives the result 2*2 matrix value from 3D matrix which is as expected. But when I am writting this code like:
a_matrix=a(t,t); ---> it gives only 1*1 matrix value and
a_matrix=a(n:n:4) (t,t);----.> it gives syntex error
How I will get expected value of 2*2 matrix using this general code not using by 1st code?
Thank you.

2 comentarios

Walter Roberson
Walter Roberson el 30 de Mayo de 2020
%for any given t value
a_matrix = reshape(a(t,t,:),2,2).';
anindita Roy
anindita Roy el 30 de Mayo de 2020
Yes.It is working. Thank you.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Mayo de 2020

Editada:

el 30 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by