Reshape matrix with zero value
3 ビュー (過去 30 日間)
古いコメントを表示
I have this variable formatted as following:
>> dist
dist =
0 7.5000 15.0000 16.7705 21.2132 16.7705 15.0000 7.5000
7.5000 0 7.5000 10.6066 16.7705 15.0000 16.7705 10.6066
15.0000 7.5000 0 7.5000 15.0000 16.7705 21.2132 16.7705
16.7705 10.6066 7.5000 0 7.5000 10.6066 16.7705 15.0000
21.2132 16.7705 15.0000 7.5000 0 7.5000 15.0000 16.7705
16.7705 15.0000 16.7705 10.6066 7.5000 0 7.5000 10.6066
15.0000 16.7705 21.2132 16.7705 15.0000 7.5000 0 7.5000
7.5000 10.6066 16.7705 15.0000 16.7705 10.6066 7.5000 0
I have just posted this question before but I'm not quite clear in the explatation. I want to obtain a 8x7 matrix because I want to eliminate all the 0 element rows by rows. How can I do this?
It should be a matrix like this:
7.5000 15.0000 16.7705 21.2132 16.7705 15.0000 7.5000
7.5000 7.5000 10.6066 16.7705 15.0000 16.7705 10.6066
15.0000 7.5000 7.5000 15.0000 16.7705 21.2132 16.7705
and so on.
Is it possible to do this thing?
0 件のコメント
採用された回答
その他の回答 (1 件)
Andrei Bobrov
2014 年 2 月 22 日
n = size(dist1);
out = zeros(n-[1 0]);
out(:)=dist(~eye(n));
out = out';
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!