フィルターのクリア

How Change Matrix Shape / Setting

1 回表示 (過去 30 日間)
Juan Pablo
Juan Pablo 2019 年 12 月 2 日
コメント済み: Juan Pablo 2019 年 12 月 2 日
Hi, I would like to change the values of these matrix in a new array
A = First Column
B = Second Column,
So, I want to have these new matrix setting:
Where:
First Row = A(1,1);B(1,2);A(2,1);B(2,2);A(7,1);B(7,2);A(8,1);B(8,2), and so on with the other rows.
Thanks for your help guys,

採用された回答

ME
ME 2019 年 12 月 2 日
Not necessarily a pretty solution but the below will do what you want for the given table. Should give you enough of an idea of how to adjust it for other examples too.
B = [reshape([A(1:2,1:2); A(7:8,1:2)]',[1 8]);reshape([A(3:4,1:2); A(9:10,1:2)]',[1 8]);reshape([A(5:6,1:2); A(11:12,1:2)]',[1 8])]
  2 件のコメント
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 12 月 2 日
Your solution works well for the requirement, contributing a bit to your answer could also be done:
B=cell2mat(mat2cell(reshape(A',4,[]),4,repmat(numel(A)/8,1,2))')'
Juan Pablo
Juan Pablo 2019 年 12 月 2 日
Thanks for your help Jesus!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by