フィルターのクリア

Rearranging a 512x64 matrix into a 32x1024 matrix

2 ビュー (過去 30 日間)
Shanice Kelly
Shanice Kelly 2021 年 1 月 12 日
編集済み: Bruno Luong 2021 年 1 月 13 日
I have a 512x64 matrix imported from a excel file. I need to turn it into a 32 x1024 matrix by keeping row 1 column 1 and row 1 column 2 elements in their position and moving all other columns in row 1, and also moving the elements of the other 511 rows.
so row 1 column 3 moves to row 2 column 1
row 1 column 4 moves to row 2 column 2
row 1 column 5 moves to row 3 column 1
row 1 cloumn 6 moves to row 3 column 2
etc... so row 1 transforrms from 1x64 to 32x2
Then move to rearranging row 2
row 2 column 1 moves to row 1 column 3
row 2 column 2 moves to row 1 column 4
I would like to do this for all 512 row until I have a 32 x1024 matrix. I really hope I explained that well enough. I really do not want to have to do this manually in excel so thank you in advance for any help.

採用された回答

Bruno Luong
Bruno Luong 2021 年 1 月 13 日
編集済み: Bruno Luong 2021 年 1 月 13 日
% Assuming A is your input matrix of size 512 x 64
% such as
% A=reshape(1:512*64,64,512)';
B = reshape(permute(reshape(A,[512 2 32]),[3 2 1]),[32 1024]);

その他の回答 (1 件)

Matt J
Matt J 2021 年 1 月 12 日
編集済み: Matt J 2021 年 1 月 12 日
  2 件のコメント
Shanice Kelly
Shanice Kelly 2021 年 1 月 12 日
Thank you for answering. I've tried reshape, unfortunately the order the values are placed in the new matrix seem to be arbitrary. I need values to be placed in a specific order or the rest of my processing will be incorrect.
Matt J
Matt J 2021 年 1 月 13 日
編集済み: Matt J 2021 年 1 月 13 日
The order is not arbitrary. It extracts data from the initial matrix column-by-bolumn and fills the new matrix column-by-column, e.g.,
A = (1:8).'
A = 8×1
1 2 3 4 5 6 7 8
B = reshape(A,[2,4])
B = 2×4
1 3 5 7 2 4 6 8

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

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by