Tune Inlined Parameters with MATLAB Language

This procedure describes how you can tune inlined parameters through the MATLAB® interface. You must have already built and downloaded the model ex_slrt_inlined_osc (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_inlined_osc')))). The model must already be running.

Note

Simulink® Real-Time™ does not support parameters of multiword data types.

You can tune inlined parameters using a parameter ID.

  • To get the ID of the inlined parameter that you want to tune, use the getparamid function. For the block_name parameter, leave a blank ('').

  • To set the new value for the inlined parameter, use the setparam function.

  1. Save the following code in a MATLAB file. For example, change_inlineA.

    tg = slrt; %Create Simulink Real-Time object
    pid = getparamid(tg, '', 'A'); %Get parameter ID of A
    
    if isempty(pid) %Check value of pid.
        error('Could not find A');
    end
    
    setparam(tg, pid, 100); %If pid is valid, set parameter value.
  2. Execute that MATLAB file. Type:

    change_inlineA
  3. To see the new parameter value, type:

    tg.ShowParameters = 'on'

    The tg object information is displayed, including the parameter lines:

    NumParameters = 1  
    ShowParameters = on  
    Parameters = INDEX  VALUE  TYPE   SIZE  PARAMETER NAME  BLOCK NAME  
                  0      100  DOUBLE Scalar A 

Related Topics