1

I'm creating a SIMULINK Library and I have made the following component: Comp1Comp2

And the function is:

function [m_out, Pt_out, Tt_out] = fcn(m_in, Pt_in, Tt_in)
    coder.extrinsic('get_param')
    PR = get_param('TURBO/Compressor Stage','PR');
    DT = get_param('TURBO/Compressor Stage','DT');
    m_out = m_in;

    Pt_out = 0;
    Pt_out = PR * Pt_in;

    Tt_out = 0;
    Tt_out = Tt_in + DT;
end

I would like the function to be able to access the block properties dynamically. Meaning that I would like to replace 'TURBO/Compressor Stage' with '[dynamic name of model]/[dynamic name of block]' (or something equivalent). Essentially, I would like the user of the library to be able to make their own model and use the component as many times as they need while setting the parameters independently.

GiaFil7
  • 141
  • 1
  • 3
  • 10
  • Did you try to create a Simulink model with those equations and add a mask to the subsystem with the "PR" and "DT" variables? – Marco Torres Nov 29 '21 at 18:13
  • @MarcoTorres The above component is a "dummy" component used as a proof of concept. What I'm actually intending to make will be far more complex than this, therefore I need a function. However, I did find that using a "MATLAB System" block does the job (even though it's not exactly what I asked in the question) – GiaFil7 Nov 30 '21 at 04:38

0 Answers0