フィルターのクリア

4x1 4 matrix conversion to 4x4 4 matrix

3 ビュー (過去 30 日間)
dhlee
dhlee 2021 年 8 月 24 日
コメント済み: dhlee 2021 年 8 月 26 日
I want to convert 4x1 4 matrix to 2x2 4 matrix as below.
How should I make script?
a=[0; 0; 0; 0]
b=[1; 2; 3; 4]
c=[5; 6; 7; 8]
d=[0; 0; 0; 0]
->
e1=[0 1; 5 0]
e2=[0 2; 6 0]
e3=[0 3; 7 0]
e4=[0 4; 8 0]
------ Please fix my code. Thank you~
close all;
clc;
clear all;
a=[0; 0; 0; 0]
b=[1; 2; 3; 4]
c=[5; 6; 7; 8]
d=[0; 0; 0; 0]
for k=1:4
e=[a(k,1) b(k,1);c(k,1) d(k,1)]
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 24 日
a=[0; 0; 0; 0]
b=[1; 2; 3; 4]
c=[5; 6; 7; 8]
d=[0; 0; 0; 0]
for k=1:4
e{k}=[a(k,1) b(k,1);c(k,1) d(k,1)]
end
  1 件のコメント
dhlee
dhlee 2021 年 8 月 26 日
Thank you

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

その他の回答 (1 件)

Chunru
Chunru 2021 年 8 月 24 日
a=[0; 0; 0; 0];
b=[1; 2; 3; 4];
c=[5; 6; 7; 8];
d=[0; 0; 0; 0];
eall =[a b c d];
for i = 1:4
e = reshape(eall(i,:), [2 2])'
end
e = 2×2
0 1 5 0
e = 2×2
0 2 6 0
e = 2×2
0 3 7 0
e = 2×2
0 4 8 0
%e1=[0 1; 5 0]
%e2=[0 2; 6 0]
%e3=[0 3; 7 0]
%e4=[0 4; 8 0]
  1 件のコメント
dhlee
dhlee 2021 年 8 月 26 日
Thank you

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by