How to define the variables as 'Global variables' within a Matlab Function block in Stateflow?
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to read some variables calculated in a Matlab Function defined in stateflow without calling them locally by the variable names and function name. A simple stateflow program is shown below.
In the stateflow chart, I have defined two Matlab functions to calculate the mean, sum and std.
These two functions are written as below.
function [meanv, sumv] = meanstats(vals)
meanv=mean(vals);
sumv=sum(vals);
function stdev = stdevstats(vals)
stdev = std(vals);
I modified the representation a bit as:
But, I want to access the outputs or Calculated values of the Functions without calling them in the State together with the FunctionName but just executing the function only, as below. But those output calculations should be displayed out of the state machine, and will be used in different calculations.
How can I define any variable globally in a Matlab Function that is to be accessed from anywhere in the program, because in the real program I have to define many variables within the same function?
0 Commenti
Risposte (1)
Jesús Zambrano
il 15 Set 2021
A way to solve this question could be by:
First, in the chart properties, set the "Export chart level functions" and "Treat exported functions as globally visible":
Then, use two Function Caller blocks, and call the functions as they were defined inside the chart:
Hope it helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Complex Logic in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!