Domanda

I'm making a GUI with Matlab that runs an initialization file (full of variables), and then simulates a Simulink file with these variables. However, the Simulink model doesn't import these variables from the workspace into it so I get errors of undefined values, etc. Is there anyway to fix this? I'm not able to specifically tell the Simulink file what variables need to be used since I'm making this GUI for an overall usage of different initialization files/Simulink models, and the amount of variables from the initialization file is in the hundreds.

Here is my code (brief):

open_system(fullfile_loadSimulink)

run(fullfile_loadInitialization)

run(fullfile_loadInitialization2)

sim(fullfile_loadSimulink)

It's straight forward, the fullfileXXX is just the string and path to each file. This even works straight from the command line, so there must be something going on with the workspaces not matching up within the GUI.

Thanks in advance.

È stato utile?

Soluzione

Sounds like your code is a function, not a script. Is that correct? If so, your function should be a script, otherwise the function has its own workspace and the Simulink model runs in the base workspace.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top