Search code examples
matlabsimulink

How can I programmatically set the inputs and outputs of a Matlab Function block to other simulink blocks?


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!


Solution

  • 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')