Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access workspace variables from embedded functions in Simulink

1,476 views
Skip to first unread message

Patrick

unread,
May 4, 2009, 12:27:01 PM5/4/09
to
Hi,

I have a Simlink model that uses lots of constants, i.e. variables created in the Matlab workspace by an initialization script. There are a few parts of the model that is implemented using embedded Matlab functions. I'd like to be able to use these constants in the embedded functions.

I've tried declaring the variables as "global", but the global declaration in the embedded functions generates an error.

Thanks for any help.

Michael Hosea

unread,
May 4, 2009, 1:27:35 PM5/4/09
to
1. Add them to the input argument list of the function.
function y = fcn(u,a_constant)

2. Open the model explorer, click on the Embedded MATLAB block, and click on
the new input argument in the center pane.

3. In the pane on the right, change the scope from "Input" to "Parameter".

4. The "Tunable" check box should have appeared to the right of the Scope
dropdown after you selected "Parameter". Uncheck the box (makes the
parameter non-tunable, aka constant).

--
Mike

"Patrick " <p...@epfl.invalid> wrote in message
news:gtn50l$8eu$1...@fred.mathworks.com...

0 new messages