Sort isn't properly sorting symbolic variables even though I am assuming them positive
Mostrar comentarios más antiguos
I have this vector "FrecuenciasCorregidas" with 2 values (both depend on "k" and "m"):

I want it to be sorted, so the lower one (3k/20m) goes first and the higher one (k/3m) goes second. So I assume k and m positive and sort:
assume([m,k],'positive');
FrecuenciasCorregidas=sort(FrecuenciasCorregidas,'ascend')
assume([m,k],'clear');
However, I am still getting the same vector:

Any idea what am I doing wrong? Thanks
3 comentarios
Vladimir Sovkov
el 27 de Jun. de 2020
It looks that the symbolic sort function has very limited applicablity. According to Matlab HELP:
sort uses the following rules:
- It sorts symbolic numbers and floating-point numbers numerically.
- It sorts symbolic variables alphabetically.
- In all other cases, including symbolic expressions and functions, sort uses internal sorting rules.
No explanation what are the internal sorting rules.
It seems that in your case it just do it alphabetically.
El Vapor
el 27 de Jun. de 2020
Vladimir Sovkov
el 27 de Jun. de 2020
No one promised it would.
Respuestas (1)
Pablo García Fogeda Núñez
el 3 de Jul. de 2020
0 votos
Te he pillado mamón.
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!