フィルターのクリア

Matching port number in two simulink model

4 ビュー (過去 30 日間)
Hariom Singh
Hariom Singh 2018 年 9 月 19 日
回答済み: Raghunandan V 2018 年 10 月 5 日
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

採用された回答

Raghunandan V
Raghunandan V 2018 年 10 月 5 日
%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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by