how can i replace the n lowest elements(ascending order) of a cell by some defined function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
studentambitious
am 16 Nov. 2015
Beantwortet: Walter Roberson
am 16 Nov. 2015
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!