How do you maintain value order when removing zeros from a matrix?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am trying to remove zeros from my matrix, so I have one column of dates, but they need to be maintained in the right order.
First_SP = SP_Marker_C(cellfun(@(x) ~isequal(x, 0), SP_Marker_C));
This removes my zeros, it reorders all the dates though, is it possible to remove the zeros but keep them in the original order?
Thanks for any help/advice/direction!
0 件のコメント
回答 (1 件)
Andrei Bobrov
2015 年 6 月 2 日
編集済み: Andrei Bobrov
2015 年 6 月 2 日
SP_Marker_C(~cellfun('ischar',SP_Marker_C)) = {[]};
or
SP_Marker_C(cellfun(@(x)x == 0,SP_Marker_C)) = {[]};
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!