4x1 4 matrix conversion to 4x4 4 matrix
18 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Walter Roberson
on 24 Aug 2021
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
More Answers (1)
Chunru
on 24 Aug 2021
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]
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!