4x1 4 matrix conversion to 4x4 4 matrix
18 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个)
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
%e1=[0 1; 5 0]
%e2=[0 2; 6 0]
%e3=[0 3; 7 0]
%e4=[0 4; 8 0]
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!