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 Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by