how can i replace the n lowest elements(ascending order) of a cell by some defined function

3 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Nov 2015
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.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by