I want to sort the positive integer values from a given values of real, rational, negative values in an array.
1 回表示 (過去 30 日間)
古いコメントを表示
I want to sort the positive integer values from a given values of real, rational, negative values in an array. Suppose, I have a=[0.2, 0.78, -3, 10, 0.8, -6, 2, -5, 3, 0.6, 8 ] then answer should be a= 10, 2, 3, 8.
0 件のコメント
回答 (3 件)
Adam
2016 年 9 月 22 日
tol = 1e-5;
a = a( a > 0 & abs( floor(a) - a ) < tol );
should work I think. Certainly it works on your example vector
0 件のコメント
参考
カテゴリ
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!