Simulink has access to any variable defined in the MATLAB workspace. You do not need to declare a variable 'global'. In order to define a variable in the MATLAB workspace from a function, you can declare the variables in the function using the command EVALIN. For example:
function declare_variable
...
evalin('base','k=100');
...
In this example, when the function 'declare_variable' is called, it will generate a variable 'k' in the MATLAB workspace. This variable can then be seen by the Simulink model. Please note that if, before the function 'declare_variable' is called, a variable called 'k' exists in the MATLAB workspace already, calling the function 'declare_variable' will overwrite the existing variable 'k' with the new value (100).
For more information on the EVALIN function, see the following URL:
Best Answer