how can i replace the n lowest elements(ascending order) of a cell by some defined function
3 ビュー (過去 30 日間)
古いコメントを表示
studentambitious
2015 年 11 月 16 日
回答済み: Walter Roberson
2015 年 11 月 16 日
I have a cell of 256x256. I want to replace the n lowest values of a cell by some defined function. the element position shall remain the same... please help
0 件のコメント
採用された回答
Walter Roberson
2015 年 11 月 16 日
In order to be able to replace the n lowest values of the cell, you need to be able to "order" the cell elements ("order" is the underlying mathematical principle of "sorting"). In general that cannot be done, just like you cannot uniquely sort complex numbers.
The ability to sort cells is defined in MATLAB only for cell arrays of strings.
If the cells happen to contain scalar (non-complex) numeric values then you can convert the cell to a numeric array and sort that to find the lowest values.
For anything else, you need to define a function that is able to take two of your cell inputs and output the relationship between them, whether the first is "less than" the second or not. Being able to test "equal to" also helps.
If you have such a function then you can begin your task of replacing the 15 "lowest" values.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!