Effacer les filtres
Effacer les filtres

Matching port number in two simulink model

3 vues (au cours des 30 derniers jours)
Hariom Singh
Hariom Singh le 19 Sep 2018
I have two simulink model , both of them has same signal names but are assigned with different port number . For example
model1.slx
Engine_State_ECU_1_1_3 port number is 23
same in
model2.slx
Engine_State_ECU_1_1_3 port number is 25
There are almost 2 thousand such port how to synchronize port numbers

Réponse acceptée

Raghunandan V
Raghunandan V le 5 Oct 2018
%find all inports from both system
Allinports1=find_system('PortSync/Subsystem1','BlockType','Inport');
Allinports2=find_system('PortSync/Subsystem2','BlockType','Inport');
for k=1: length(Allinports1)
%get the port number of all the inports in the first subsystem
PortNum=get_param(Allinports1{k,1},'Port');
%to find the port name only you have to find the '/' indexes
Index1=strfind(Allinports1{k,1},'/');
%once you find the indices, we know that the port name is the last part
%of the full address of the port
PortName1=Allinports1{k,1}((Index1(end)+1):end);
for j=1: length(Allinports2)
%same steps as above is followed for the second subsystem too
Index2=strfind(Allinports2{j,1},'/');
PortName2=Allinports2{j,1}((Index2(end)+1):end);
%if there is a common name then set the second subsystem port number same
%as first one
if PortName1==PortName2
set_param(Allinports2{j,1},'Port',PortNum);
end
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by