Create siumlink model using script.
2 views (last 30 days)
Show older comments
Satya jain
on 24 Jul 2020
Edited: Walter Roberson
on 24 Jul 2020
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.
0 Comments
Accepted Answer
Walter Roberson
on 24 Jul 2020
Edited: Walter Roberson
on 24 Jul 2020
src_signal = signal{x,1} + "/1";
dst_signal = "BC1/" + x;
add_line('test', src_signal, dst_signal);
0 Comments
More Answers (0)
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!