Stateflow: function call during action v/s fuction call during condition check

I am working on State flow in which I am calling a function "func1" and assigning the output of that function to a Variable "Temp". After that performing the conditional check by using another function "func2(Temp)" by passing the "Temp" variable to it.
The problem is func2 is using the old value of Temp but not the latest value of Temp=func1() (which is assigned at current event).
Using the debugger I figured it out that func2() is called before the func1().
MATLAB is calling func2() first because to perform the conditional check and decide the path. After decide the path it calls the function func1();
Is there any solution by which I can use the value of "Temp" for the conditional check.
Temp = func1();
if func2(Temp) % code end

1 Comment

You have not mentioned where are you calling these functions inside a state (entry action, during action or some transition). Try calling these functions on transitions and call func1 at a transtion that is going to be executed first.

Sign in to comment.

Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products

Tags

Asked:

on 26 Apr 2013

Community Treasure Hunt

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

Start Hunting!