Changing matrices form, echelon the matrices

조회 수: 1 (최근 30일)
tevzia
tevzia 2014년 1월 14일
편집: Azzi Abdelmalek 2014년 1월 14일
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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 14일
편집: Azzi Abdelmalek 2014년 1월 14일
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개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by