Changing matrices form, echelon the matrices
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
tevzia
il 14 Gen 2014
Modificato: Azzi Abdelmalek
il 14 Gen 2014
Hello,
I have a matrices that i want to change the form/type of it. My array is lik that
A B C D
A 0 1 0 0
B 0 0 1 1
C 0 0 0 1
D 0 0 0 0
And i want to change this matrices like this:
A, A, 0
A, B, 1
A, C, 0
A, D, 0
B, C, 1
B, D, 1
C, D, 0
Or like this;
A, A, 0
A, B, 1
A, C, 0
A, D, 0
B, A, 0
B, B, 0
B, C, 1
B, D, 1
C, A, 0
C, B, 0
C, C, 0
C, D, 1
D, A, 0
D, B, 0
D, C, 0
D, D, 0
I would appreciate if you show me how to change it.
Thanks
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 14 Gen 2014
Modificato: Azzi Abdelmalek
il 14 Gen 2014
A=[0 1 0 0
0 0 1 1
0 0 0 1
0 0 0 0]
%For the first case
n=size(A,1)
out=[A(1,:)';cell2mat(arrayfun(@(x) A(x,x+1:n)',(2:n-1)','un',0))]
% Forthe second case
B=A';
B=B(:)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Types in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!