0

I'm trying to programatically create several Matlab Function blocks to have their input set to the output of a Mux block, and their output set to the signal port of an Output Switch block.

I've created some basic Simulink models in the past using the add_block and add_line functions, but it seems Matlab Function blocks work differently.

I know what I'm trying to do can be achieved since I've done it manually, but I need to achieve this programatically to create large models.

Thanks!

2
  • What do you mean by set? Do you mean connect the input (resp. output) to the output (resp. input) of another block? Commented Dec 4, 2014 at 10:52
  • Yes that's exactly what I mean. Any suggestions? Commented Dec 5, 2014 at 3:03

1 Answer 1

1

It should work. Consider for example a Simulink model with a constant block, a MATLAB Function and a Scope block. Try the following:

add_line('untitled','Constant/1','MATLAB Function/1')
add_line('untitled','MATLAB Function/1','Scope/1')
Sign up to request clarification or add additional context in comments.

4 Comments

That worked! Thank you! My mistake was how I was refering to the ports in the function block (RConn1 | LConn1). My bad, since I just recently started learning Simulink by example.
Would you be kind enough to point me to a resource so that lets me discover things such as the port names of different blocks etc?
Check the documentation for add_line: "Most block ports are identified by numbering the ports from top to bottom or from left to right, such as 'Gain/1' or 'Sum/2'. Enable, Trigger, State, and Action ports are identified by name, such as 'subsystem_name/Enable', 'subsystem_name/Trigger', 'Integrator/State', or 'if_action_subsystem_name/Ifaction'.
Thank you very much. I'll check the documenation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.