HOW TO RESHAPE 3D ARRAY WITH DIFFERENT DIRECTIONS?

2 ビュー (過去 30 日間)
Triveni
Triveni 2021 年 8 月 21 日
編集済み: DGM 2021 年 8 月 21 日
for i = 1:length(j)
NETPLP(:,:,i)= [BPavg1(1,1,i), SPavg1(1,1,i), NETPLP1(1,1,i); BPavg2(1,1,i), SPavg2(1,1,i), NETPLP2(1,1,i); BPavg3(1,1,i), SPavg3(1,1,i), NETPLP3(1,1,i); BPavg4(1,1,i), SPavg4(1,1,i), NETPLP4(1,1,i); BPavg5(1,1,i), SPavg5(1,1,i), NETPLP5(1,1,i); BPavg6(1,1,i), SPavg6(1,1,i), NETPLP6(1,1,i); BPavg7(1,1,i), SPavg7(1,1,i), NETPLP7(1,1,i); BPavg8(1,1,i), SPavg8(1,1,i), NETPLP8(1,1,i)];
end
PL1 = reshape(permute(NETPLP(1,:,:),[1,3,2]), size(NETPLP(1,:,:),1)*size(NETPLP(1,:,:),3), 3);
PL2 = reshape(permute(NETPLP(2,:,:),[1,3,2]), size(NETPLP(2,:,:),1)*size(NETPLP(2,:,:),3), 3);
PL3 = reshape(permute(NETPLP(3,:,:),[1,3,2]), size(NETPLP(3,:,:),1)*size(NETPLP(3,:,:),3), 3);
PL4 = reshape(permute(NETPLP(4,:,:),[1,3,2]), size(NETPLP(4,:,:),1)*size(NETPLP(4,:,:),3), 3);
PL5 = reshape(permute(NETPLP(5,:,:),[1,3,2]), size(NETPLP(5,:,:),1)*size(NETPLP(5,:,:),3), 3);
PL6 = reshape(permute(NETPLP(6,:,:),[1,3,2]), size(NETPLP(6,:,:),1)*size(NETPLP(6,:,:),3), 3);
PL7 = reshape(permute(NETPLP(7,:,:),[1,3,2]), size(NETPLP(7,:,:),1)*size(NETPLP(7,:,:),3), 3);
PL8 = reshape(permute(NETPLP(8,:,:),[1,3,2]), size(NETPLP(8,:,:),1)*size(NETPLP(8,:,:),3), 3);
PL= [PL1;PL2;PL3;PL4;PL5;PL6;PL7;PL8];
LENGTH(J) = 20. IN WHICH I GOT
I WANT VALUES OF PL WITHOUT ASSIGNING THE VARIABLE PL1, PL2, P3, PL4, PL5, PL6, PL7 AND PL8.
PLEASE HELP ME.
  3 件のコメント
Triveni
Triveni 2021 年 8 月 21 日
編集済み: darova 2021 年 8 月 21 日
I have tried this earlier but
PL=NETPLP(1:8,:,:)
PL(:,:,1) =
22 22.05 11.04
22 21.95 -13.96
20.95 21 11.06
21.05 21 -13.94
22 21.95 -13.96
22 20.95 -263.95
22.05 21 -263.95
20.95 21 11.06
I have to rearrange this array. I have to select 1st row from each array then 2nd row to each array and so on. then i have to merge all into single matrix.
DGM
DGM 2021 年 8 月 21 日
What are the sizes of BPavg#, SPavg#, NETPLP#?

サインインしてコメントする。

採用された回答

DGM
DGM 2021 年 8 月 21 日
編集済み: DGM 2021 年 8 月 21 日
This is why using numbered variables instead of arrays is a bad idea.
No need for a loop. Depending on the size of the inputs, just address the arrays accordingly (pick one)
% assuming that BPavgN, SPavgN, NETPLPN are all mxnx20
NETPLP = [BPavg1(1,1,:), SPavg1(1,1,:), NETPLP1(1,1,:);
BPavg2(1,1,:), SPavg2(1,1,:), NETPLP2(1,1,:);
BPavg3(1,1,:), SPavg3(1,1,:), NETPLP3(1,1,:);
BPavg4(1,1,:), SPavg4(1,1,:), NETPLP4(1,1,:);
BPavg5(1,1,:), SPavg5(1,1,:), NETPLP5(1,1,:);
BPavg6(1,1,:), SPavg6(1,1,:), NETPLP6(1,1,:);
BPavg7(1,1,:), SPavg7(1,1,:), NETPLP7(1,1,:);
BPavg8(1,1,:), SPavg8(1,1,:), NETPLP8(1,1,:)];
% if they are 1x1x20
NETPLP = [BPavg1, SPavg1, NETPLP1;
BPavg2, SPavg2, NETPLP2;
BPavg3, SPavg3, NETPLP3;
BPavg4, SPavg4, NETPLP4;
BPavg5, SPavg5, NETPLP5;
BPavg6, SPavg6, NETPLP6;
BPavg7, SPavg7, NETPLP7;
BPavg8, SPavg8, NETPLP8];
The rest seems simple enough
% reshape the array
PL = reshape(permute(NETPLP,[3 1 2]),[],3);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by