How to - "sort" using mexCallMATLAB ?
Mostrar comentarios más antiguos
Dear all,
I am writing a mex-function and need to sort some data using the mexCallMATLAB API so that I get the data in the required form. i.e I need the data in descending order along with the index values.
In matlab - [y,i] = sort(x,1,'descend'); does the job for me. Can I simulate the same through the mexCallMATLAB API? If yes, how does it fit in the syntax for the API?
or
Should I write a C-code for the same?
Thanks in advance
Respuesta aceptada
Más respuestas (1)
Kaustubha Govind
el 1 de Nov. de 2011
0 votos
Yes, you should be able to call into the MATLAB 'sort' implementation using mexCallMATLAB. Whether or not to implement your own algorithm in C is subjective. There is potential for performance improvement in some cases because MATLAB functions are interpreted and there is overhead for data marshaling, but it appears that the MATLAB sort is multithreaded, so you might not be able to do any faster than MATLAB can, unless you plan to call into some highly-optimized libraries. If performance is very important to you, perhaps you should perform some benchmarking to see if the MATLAB implementation is good enough for your application.
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!