title: Programmatically change input to parameter in MATLAB Function block
body: <p>I have a <a href="http://www.mathworks.com/help/simulink/slref/matlabfunction.html" rel="nofollow noreferrer">MATLAB Function</a> block wrapped in a masked subsystem. The subsystem's mask has a parameter <code>p1</code> which I want to use inside the MATLAB function. How to do this manually is <a href="http://www.mathworks.com/help/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html" rel="nofollow noreferrer">described in the documentation</a>. However, I need to do this programmatically and so far I've failed to figure out how to do this.</p>
  
  <p>Adding the parameter to the subsystem's mask programmatically <a href="http://www.mathworks.com/help/simulink/ug/control-masks-programmatically.html" rel="nofollow noreferrer">is easy using <code>Simulink.Mask.addParameter</code></a>, as is <a href="https://stackoverflow.com/q/19494423/857390">creating the MATLAB Function block</a> and <a href="https://stackoverflow.com/a/22706370/857390">setting its code</a>. The hard part is to programmatically switch the scope of the function argument <code>p1</code> from "Input" to "Parameter" (Steps 2-4 in the <a href="http://www.mathworks.com/help/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html" rel="nofollow noreferrer">documentation</a>). I couldn't find where this information is stored (I checked both the "traditional" Simulink block parameters and the Stateflow object associated with the block).</p>