How to define and output signals in array form from stateflow chart ?

7 views (last 30 days)
I want to output multiple values from Stateflow Chart in form of array.
Say V_fan[] is array of order 2
i is index i.e. V_fan[i]=1;
say V_fan[0]=0 and V_fan[1]=1;
how to define that inside stateflow chart such that V_fan[i] is output variable.
I tried to define {i=0} on default block condition and in state with
entry:V-fan{i}=0;
I am getting error as Varargout expected. Code generation supports cell subscripted assignment for varargout only.
State 'FanOff' (#80) "V_fan{i}"
please refer this link see the video for first few minutes and you will understand better.
Thanks Prasad

Accepted Answer

Sebastian Castro
Sebastian Castro on 20 May 2015
Edited: Sebastian Castro on 20 May 2015
Given the syntax you are using, I'm assuming you are using the C action language. In that case, I see 2 syntax errors in that statement which is giving you problems.
  1. First off, you entered V-fan instead of V_fan as the variable name
  2. Secondly, C action language charts should index arrays with square brackets [ ] and not curly braces { }. This was the reason you got the error message.
I made a simple chart with your default transition action {i=0;} and the following state entry action and it worked fine.
entry: V_fan[i] = 0;
- Sebastian

More Answers (1)

Prasad Desai
Prasad Desai on 21 May 2015
Thanks Sebastian

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!