- Right-click the library and open it outside the Library Browser
- Navigate to, and select, the block you're interested in adding
- Enter gcb in MATLAB to get the exact block path you should use
How to add Simulink Library Block programmatically ?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jan Svanda
am 25 Sep. 2015
Bearbeitet: Sebastian Castro
am 25 Sep. 2015
Hi,
I try to generate a Simulink model with using add_block() function programmatically. I have an issue with a block path. When I use following example everything is ok.
sys = 'testModel';
new_system(sys) % Create the model
open_system(sys) % Open the model
pos = [30 37 60 50 ];
add_block('simulink/Sinks/Scope',[sys '/In1'],'Position',pos);
But if I try to insert another blocks I get an error : There is no block named 'NI VeriStand Blocks/NIVeriStand In1'
sys = 'testModel';
new_system(sys) % Create the model
open_system(sys) % Open the model
pos = [30 37 60 50 ];
add_block('NI VeriStand Blocks/NIVeriStand In1',[sys '/In1'],'Position',pos);

I thought that the path is same like in Simulink Library Browser, but it’s wrong probably
Is there any way how to found the path to the Simulink blocks?
Thanks Jan
0 Kommentare
Akzeptierte Antwort
Sebastian Castro
am 25 Sep. 2015
Bearbeitet: Sebastian Castro
am 25 Sep. 2015
The name of the model is not the same as what shows up on the Library Browser. It just happens to be so for "Simulink", whose library file name is simulink.slx.
If you right-click the "NI VeriStand Blocks" library and select "Open NI VeriStand Blocks library", it will bring up the model file, which will tell you the actual name of the model. I can't tell you what that is since NI VeriStand is a third-party library and I don't have it.
Take this other one as an example. If you right-click your DSP System Toolbox library and open it in the above fashion, the model name (in R2015b) will be dsplibv4. Furthermore, when you click "Sources", it will open a new model called dspsrcsv4.
Bottom line: You can't tell the path of the block by looking at its user-visible name. Best thing to do is to
- Sebastian
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Model Editing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!