Changing matrices form, echelon the matrices

1 vue (au cours des 30 derniers jours)
tevzia
tevzia le 14 Jan 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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 14 Jan 2014
Modifié(e) : Azzi Abdelmalek le 14 Jan 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(:)

Plus de réponses (0)

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!

Translated by