Is it possible to organize variables shown in workspace?

17 visualizaciones (últimos 30 días)
Zeynab Mousavikhamene
Zeynab Mousavikhamene el 5 de Sept. de 2019
Editada: Stephen23 el 5 de Sept. de 2019
I am interested to arrange parameters shown in the workspace based on the script. I have two scripts now and one script calls the other one. At the end of simulation variables of two scripts are shown in workspace alphabetically. Is it possible to sort them by script so that the variables of script one are shown first and then the variables of script two?

Respuestas (1)

Stephen23
Stephen23 el 5 de Sept. de 2019
Editada: Stephen23 el 5 de Sept. de 2019
"At the end of simulation are variables of two scripts are shown in workspace alphabetically. Is it possible to sort them by script?"
No.
It doesn't even make sense, because variables in a workspace do not have an "order". How they are displayed is simply an artefact of the displaying functionality of the MATLAB IDE, which is not specified to be in any particular "order", it could also change between different MATLAB versions.
In contrast (and by definition) all arrays do have an order: the 1st array element comes 1st, the 2nd array element comes 2nd, etc.
If you want to sort data into a specific order, you need to use an array (which could be a numeric array, a cell array, a structure array, a table, etc.).
Note that putting meta-data into variable names (which most likely you have) is not recommended. Accessing meta-data in variable names is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know why:

Categorías

Más información sobre Matrices and Arrays 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