Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to share a lot of global variables in matlab bloc function?

1 次查看(过去 30 天)
Hello everyone, I am trying to use a matlab function bloc in a Simulink model. This matlab function calls other matlab functions during execution (locals and not locals) and in some of them I use global variables which are defined in the base workspace with a script. My problem is how to best manage the data sharing between base workspace, model workspace and function workspaces?
I have read the "Share Data Globally" documentation but I haven't really find a great solution. Indeed all matlab functions together I have a lot of globals (80 to 100) so I'd rather not use data store memory blocs (plus it doesn't seem to work for globals used in called functions, but maybe because I misused them?). I also tried to use a Simulink.Signal object but here I need to enter the Initial Value. And as it is defined in the base workspace, I have name incompatibility error.
Is there another solution I haven't heard of? I am considering using a data dictionary, but I don't know if it will do the job. Does anyone has any vision on this?
I know that using global variables is not recommended because it makes the debugging process difficult. But all my globals are design constants and thus aren't changed during simulations (a nominal power for example). Even so I am ready not to use globals for a more robust system but then I don't which and how.
Thanks a lot for your answers

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by