4x1 4 matrix conversion to 4x4 4 matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 24 Août 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
Plus de réponses (1)
Chunru
le 24 Août 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]
Voir également
Catégories
En savoir plus sur Data Types dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!