Create siumlink model using script.

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 日

0 投票

src_signal = signal{x,1} + "/1";
dst_signal = "BC1/" + x;
add_line('test', src_signal, dst_signal);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by