Converting a 3D matrix into a 2D in the correct order.

1 Ansicht (letzte 30 Tage)
Pedro Vicente
Pedro Vicente am 19 Jun. 2018
Kommentiert: Andrei Bobrov am 19 Jun. 2018
Hi guys, so i have a index matrix of 1x8x50 (i know this is almost a vector). exemple:
T(:,:,48) = 37.3795 32.7215 31.9475 35.0683 35.8266 61.2570 45.0210 44.3608
T(:,:,49) = 38.7236 33.9132 33.1193 36.3396 37.1225 63.2087 46.5356 45.9089
And i Want to put it all in a 2D matrix with the index of (50;8). But when do reshape(T[size(T,3),size(T,2)]), it organizes the matrix by column. What i would like is that each 3D matriz would be a row of my 2D matrix. Like T(:,:,1) would be the first line of the 2D matrix and so on.
Thank you!!

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 19 Jun. 2018
permute(T,[3,2,1])
  2 Kommentare
Stephen23
Stephen23 am 19 Jun. 2018
Bearbeitet: Stephen23 am 19 Jun. 2018
+1 permute is the correct way to do this.
Andrei Bobrov
Andrei Bobrov am 19 Jun. 2018
Thank you Stephen!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sayyed Ahmad
Sayyed Ahmad am 19 Jun. 2018
Bearbeitet: Sayyed Ahmad am 19 Jun. 2018
for i=1:8
for j=1:50
a(1,i,j)=i*10000+j;
end
end
b=a;
b=reshape(b,8,50);
b=b';

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by