How to disable warning for Stateflow action language

4 views (last 30 days)
Jeremy on 26 Jan 2017
Commented: Jeremy on 31 Jan 2017
I am working on a script which temporarily adds content to a Simulink model, builds the model, then removes the new content. I recently started adding a few Stateflow diagrams to these models, and I use the C action language in these diagrams. My script can add the Stateflow and then change the action language to C, but I cannot find a way to do both of these things in a single command line, so the Stateflow temporarily exists with the default m-script action language.
Here's the problem. For MatLab 2015B users of this script, the following warning appears at the top of the active Simulink window:
"You are adding a chart '...' that uses MATLAB as the action language to the model. Click here to change the action language to C. To always add a C chart henseforth, click here. Learn more"
The next two lines of my script change the action langue to C, but it is too late to prevent the warning from being displayed. Other people run this script, and I do not want to change their default settings. Any suggestion on how I can disable this warning, either by adding the Stateflow chart as a C action language in one line, or by temporarily disabling the warning?

Accepted Answer

Michelle Wu
Michelle Wu on 30 Jan 2017
It does not seem possible to disable the warning. If you will be using C as the action language throughout the whole model, it looks safer and easier to me to first set the correct action language before adding a new Stateflow chart. I understand that you would like to avoid changing default action language on other people's machine, but a possible workaround could be:
  1. Save their current default setting
  2. Change the Stateflow action language to "C"
  3. Restore the previous default language at the end of the script
The code that does the job should look like:
curLanguage = sfpref('ActionLanguage'); % save the user's current language
sfpref('ActionLanguage','C'); % set the default language to C
% Your code ...
sfpref('ActionLanguage', curLanguage) % restore to previous setting
  1 Comment
Jeremy on 31 Jan 2017
Thanks, that solved it!
I had only seen sfpref used to set the default value of this setting. I didn't know it could also read the default. Thanks for showing me how this can be used to change this setting on a temporary basis.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by