Changing matrices form, echelon the matrices

2 views (last 30 days)
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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 14 Jan 2014
Edited: Azzi Abdelmalek on 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(:)

More Answers (0)

Categories

Find more on Particle & Nuclear Physics 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!