Is it possible to use "add_line()" betwen "Model Reference" Blocks

Hello !
I have a System with several "Model Reference" Blocks which have many in and out ports and i'm trying to connect each outport with its same name inport.
But when i try :
add_line(system, Model Name/Outport Name, Model Name/Inport Name);
it returns me an error.
How can i do this ?
Capture.PNG
Thanks for helping !

Answers (1)

Lucas,
Your command should be:
%Syntax: add_line('system_name', 'blockname/outport', 'blockname/inport');
add_line(gcs, 'Model/1','Model1/1');

6 Comments

Yeah i tried this but is it possible to call them by their names in the add_line() function ?
Because i need to connect same names ports but they have not the same port_number in their model
What do you mean by "call them by their names"? The add_line() needs the block names and port number. I don't think the port names matter.
Do you want use the model names the blocks are referencing? If yes, then you can rename the block names with model names and then use the add_line() command.
My system is more complicated than the example here. I mean i have to connect many Models between them. And to make that i have to connect for example "+15V" inport of Model1 to the "+15V" outport of Model 3 but port number are differents so how can i do that.
And what i forgot to say is that i create Model depending on a text file and so the model is always different.
I have thinking of comparing names of each inports and each outports of each models and connect them if it's equal but i have no more idea to do that
Arvind Sathyanarayanan I don't understand why when i do :
find_system('Subsystem Name', 'BlockType', 'Inport');
i can have all ports of the subsystem blocks, but when i do :
find_system('Model Reference Name', 'BlockType', 'Inport');
I have nothing
Can you please post of a screenshot of your actual model so I can better understand what you're trying to do?
Regarding your second comment, you need to load the system before you can use api commands. Try:
load_system('Model Reference Name');
find_system('Model Reference Name', 'BlockType', 'Inport');

Sign in to comment.

Categories

Asked:

on 26 Jun 2019

Community Treasure Hunt

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

Start Hunting!