delete NaN rows and columns but

4 ビュー (過去 30 日間)
Andrea
Andrea 2012 年 5 月 21 日
I want to remove the NaN column and row in my image so the size will be decreased, but since I used the "find' command it Matlab, it also remove the NaN that changes the shape of the image,too. I just want to remove the NaN data as much as possible but keep the other NaNs that cannot be removed in order to have the same shape.

採用された回答

per isakson
per isakson 2012 年 5 月 21 日
Is this close?
M( all( isnan( M ), 2 ), : ) = []; % removes all rows with all nans
M( :, all( isnan( M ), 1 ) ) = []; % and columns
and you might want to try the FEX contribution inpaint_nans
  2 件のコメント
Andrea
Andrea 2012 年 5 月 21 日
Thanks, It perfectly works on my code. I really appreciate your instance reply.
Claudia
Claudia 2012 年 7 月 1 日
Was just looking exactly for that! Thank you! And thanks showing both (column and rows)! It looks easy to change from row to column if you know how ... but if you don't ... can drive you crazy!

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

その他の回答 (1 件)

wenwu
wenwu 2012 年 5 月 27 日
Nice, Thx for your guys question and answer, i learned sth. Thx

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by