How to declare global variables for simulink containing matlab functions?

14,115

You need to either define your global variables as Simulink.Signal object or a Data Store Memory block and then define them as global in your MATLAB function. You cannot access the regular MATLAB variables from MATLAB workspace.

There is a detailed page about this on MAthworks website with a good example.

Share:
14,115
user10678
Author by

user10678

Updated on July 12, 2022

Comments

  • user10678
    user10678 almost 2 years

    I'm building a simulink model with multiple matlab function blocks( http://in.mathworks.com/help/simulink/slref/matlabfunction.html ). Each of these function blocks have a lot of constants, for example (g=9.8), common between them. I want to initialize all of these constants in one go so that I don't have to do so in each function block.

    I tried initialising all the variables in matlab workspace, but they don't seem to be working.

    What is the best and easiest way to go forward with this?