how can i replace the n lowest elements(ascending order) of a cell by some defined function
3 次查看(过去 30 天)
显示 更早的评论
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!