フィルターのクリア

how to create type of eye matrix

3 ビュー (過去 30 日間)
fatema saba
fatema saba 2014 年 6 月 24 日
コメント済み: fatema saba 2014 年 6 月 24 日
Hello, I have three matrix like:
z1=[5 0 1;7 9 0;10 0 0], z2=[0 1 2;5 8 0;3 9 10] and z3=[81 11 90;12 0 15;20 17 16]. you see that some of values in every matrix are zero. the number of cells that is not zero in z1 is 5 and in z2 is 7 and in z3 is 8. Now I want to make matrix on the basis of the structure of z1, z2 and z3 that has only zero and one like:
[1 1 1 0 1 0 1 0 0(on the basis of z1),0 0 0 0 0 0 0 0 0(on the basis of the number of z2),0 0 0 0 0 0 0 0 0(on the basis of the number of z3);0 0 0 0 0 0 0 0 0(on the basis of the number of z1),0 1 1 1 1 1 1 0 1(on the basis of z2),0 0 0 0 0 0 0 0 0(on the basis of the number of z3);0 0 0 0 0 0 0 0 0(on the basis of the number of z1),0 0 0 0 0 0 0 0 0(on the basis of the number of z2),1 1 1 1 0 1 1 1 1(on the basis of z3)]
Is there any idea and general way to create this matrix?
  1 件のコメント
dpb
dpb 2014 年 6 月 24 日
Please format the code/data matrices to be legible...
[1 1 1 0 1 0 1 0 0(on the basis of z1),0 0 0 0 0 0 0 0 0(on the basis of the number of z2),...
I can see that the first vector is
>> [z1(:)~=0].'
ans =
1 1 1 0 1 0 1 0 0
>>
but I see no relationship between the rest and the given relationship. You're saying z2-->zeros(1,numel(z2)).
Need better explanation of the logic.

サインインしてコメントする。

採用された回答

Mischa Kim
Mischa Kim 2014 年 6 月 24 日
編集済み: Mischa Kim 2014 年 6 月 24 日
Fatema, use
z_zero = blkdiag(z1(:)~=0,z2(:)~=0,z3(:)~=0)'
  1 件のコメント
fatema saba
fatema saba 2014 年 6 月 24 日
Thank you. you are kind angel.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by