Modify In/Output Port names with a MATLAB script

5 vues (au cours des 30 derniers jours)
Gennaro Di Sarno
Gennaro Di Sarno le 2 Mar 2023
Commenté : ciming zhu le 27 Avr 2023
Hi,
I have a simulink subsytem with a huge number of input and output ports, I need to rename all the ports names according to an excel file list.
I'd like to avoid doing it manually but I have no clue on how to write down a MATLAB script to automatically do it.
Kind Regards

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 3 Mar 2023
Modifié(e) : Fangjun Jiang le 3 Mar 2023
Something like this:
[~,~,InPortNames]=xlsread('ExcelFileName'); % read Excel file to get PortNames as a cell array
InPorts=find_system('Model/Subsystem','SearchDepth',1,'BlockType','Inport');
for k=1:length(InPorts)
set_param(InPorts{k},'Name',InPortNames{k});
end
  1 commentaire
ciming zhu
ciming zhu le 27 Avr 2023
Could you please show me how to achieve this proceed in multibody?It seems that there is no Inport in multibody.Thanks a lot.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Environment Customization dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by