Enabling bus sorting by name in the Simulink Type Editor

8 visualizaciones (últimos 30 días)
Grigorii Nefedov
Grigorii Nefedov el 9 de En. de 2024
Respondida: Gayathri el 30 de Sept. de 2024

How to enable bus sorting by name in the Simulink Type Editor?

  4 comentarios
Grigorii Nefedov
Grigorii Nefedov el 11 de En. de 2024
Editada: Grigorii Nefedov el 11 de En. de 2024
I want to sort buses in Type Editor window, not bus elements.
Mikel
Mikel el 25 de Sept. de 2024
Any updates on this??

Iniciar sesión para comentar.

Respuestas (1)

Gayathri
Gayathri el 30 de Sept. de 2024
I understand that you want to enable sorting in “Type Editor” in Simulink. Buses are usually displayed in the order in which they are added in “Type Editor”. One solution is to export the “buses” to a “MAT” file and then sort them programmatically as shown in the below code.
% Load the MAT-file
data = load('data.mat');
varNames = fieldnames(data)
% Sort the variable names alphabetically
[sortedVarNames, sortIdx] = sort(varNames)
sortedData = struct();
for i = 1:length(sortedVarNames)
sortedData.(sortedVarNames{i}) = data.(varNames{sortIdx(i)});
end
% Save the sorted bus objects back to a new MAT-file
save('sorted_data.mat', '-struct', 'sortedData');
disp('Buses sorted and saved to sorted_data.mat');
The next step would be delete all “buses” in the “Type Editor”. Use the “import” option in “Type Editor” to load the data from “sorted_data.mat”. Now the “buses” would be sorted as desired in the “Type Editor” window.
Hope you find this information helpful.

Categorías

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

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by