How can I order a matrix in a specific order?

3 visualizaciones (últimos 30 días)
Jennifer Arellana
Jennifer Arellana el 9 de Abr. de 2021
Comentada: Jennifer Arellana el 9 de Abr. de 2021
Hello to all,
I am working in Matlab with data of Ampl, so i am using amplapi. I have a problem when I call the matrices because when I check them I notice that the order is different, however, I need the matrices to have the same order to not have a problem with the rest of the code. Attached is how I have my data from a matrix in Ampl and how Matlab reads it. Please check the script. My question is how can I order my matrix in the order I want in Matlab?
Thank for your attention.

Respuesta aceptada

dpb
dpb el 9 de Abr. de 2021
I've no klew what amplapi is, but if you have a text file like the first, reading it into MATLAB will not reorder it.
>> which -all amplapi
'amplapi' not found.
>>
shows it not a part of base MATLAB nor of the (relatively few) toolboxes I have installed so we don't know what it does; on top of that you showed us no code at all from which to be able to even hypothesize something.
BUT, the first file looks to be sorted by column 3, then by column 2 and column 1 whereas the second is by colun 1, 2, and 3.
So,
x=sortrows(x,[3 2 1]);
where x is a placeholder for your MATLAB variable containing the array will produce the same sorted order.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by