MATLAB: Using global variable to define a Simulink block parameter

block parameterglobal variablesimulink

Hi, i guess it should have been simple but i cant find a solution since long time. I have a simulink model that has a "Matlab function" block. I have a parameters' function that i load each time automatically using simulink Callbacks=> InitFcn. I want my Matlab functin block to take its Sample time parameter defined in this init function, but it does not work.
but when i define the parameter manually in the matlab workspace, the block takes it.
any ideas !!
thanks in advance,
aft kh

Best Answer

In the InitFcn call, does it call a M-function or M-script? I suspect this is another case of function workspace and base workspace.
Clear the base workspace using "clear", then run whatever is in the InitFcn. Then check the base worksapce, do you see the sample time parameter?
As you indicated, you need to set the sample time parameter in the MATLAB base workspace.