Is there a way to share a variable between simulink and matlab?
Show older comments
Hi guys, I have a question about simulink and matlab interference. I run a simulink model and m file simultaneously and I need to get the value of a variable from sim model to forward the progress of m file. I'm wondering if there's a way to let simulink and m file share a variable and make it accessible to the m file so that m file can reacts to the variable's changes.
Thank you
Accepted Answer
More Answers (1)
Walter Roberson
on 21 Aug 2015
0 votes
When I investigated earlier this week I discovered that the data is written to the Base workspace if Simulink is started from the graphics menu, but if you call sim() within MATLAB then the data is written to the workspace of the function that calls sim(). (That function can then write it elsewhere.)
3 Comments
Simon
on 21 Aug 2015
Purushottama Rao
on 22 Aug 2015
I think you can use a embedded matlab function available in simulink. In your application, input for the embedded matlab function could be the peak of the external sensor signlas and then you can write a script inside it to call one more function conditionally..
Walter Roberson
on 22 Aug 2015
"embedded matlab function" is an older term. The newer is MATLAB Function Block
Categories
Find more on Large-Scale Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!