Create siumlink model using script.

2 次查看(过去 30 天)
I am trying to build a script that will create a simulink model taking the input block data from excel.
However facing difficulty in addressing the created block. i have read my data using code
%Read from Excel and open a simulink block
[~, signal] = xlsread('Com Simu mAPPNG.xlsx')
new_system('test');
open_system('test')
count= size(signal,1);
% create bus with number oif input as count.
add_block('simulink/Commonly Used Blocks/Bus Creator', 'test/BC1');
set_param('test/BC1','Inputs','count');
This works fine. When i enter the loop to create blocks names from the data read from excel (create memory read blocks).
or x=1:count
add_block('simulink/Signal Routing/Data Store Read', 'test/MemoryRead1', 'MakeNameUnique', 'on');
set_param(gcb,'Name', signal{x,1});
set_param(gcb,'Datastorename', signal{x,1});
This also works.
Now i want to add line. and to address the block
add_line('test','signal{x,1}/1','BC1/x');
Gives error
Invalid Simulink object name: signal{x,1}/1
Pls help how to address these variable.

采纳的回答

Walter Roberson
Walter Roberson 2020-7-24
编辑:Walter Roberson 2020-7-24
src_signal = signal{x,1} + "/1";
dst_signal = "BC1/" + x;
add_line('test', src_signal, dst_signal);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by