Matching port number in two simulink model

2 visualizaciones (últimos 30 días)
Hariom Singh
Hariom Singh el 19 de Sept. de 2018
Respondida: Raghunandan V el 5 de Oct. de 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

Respuesta aceptada

Raghunandan V
Raghunandan V el 5 de Oct. de 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

Más respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by