Questions tagged [stateflow]

StateFlow is a toolbox from MathWorks for development of state machines

Stateflow is an toolbox (extension) of Matlab from Mathworks. It is a commercial, and proprietary toolset.

Generally, Stateflow extends Simulink with the ability to design and test state machines. It is commonly used in control design, where algorithms can be either matlab scripts & formulas, simulink blocks or embedded code (in the form of so-called S-functions).

Code generation is supported on the host platform, but for target code additional tools are required (such as real time Workshop).

Advantages compared to software-only tooling (like IBM Rhapsody):

  • use with hardware (in the loop)
  • seemless integration with Simulink

Disadvantages compared to software-only tooling:

  • cost for code generation

Links:

81 questions
23
votes
8 answers

Unit testing/continuous integration with Simulink/Stateflow

How can I perform unit testing in Simulink, or preferably, Stateflow? I'm a fan of agile software methods, including test driven development. I'm responsible for the development of safety critical control software and we're using…
Adriaan
  • 3,232
  • 1
  • 19
  • 31
7
votes
6 answers

What's the difference between stateflow and simulink?

As far as I know, stateflow and simulink are often used at the same time, and are both environments developed by MathWorks, who make Matlab. May I know what's the difference between them?
user1487718
3
votes
2 answers

Programmatically open a Simulink MATLAB function block's code

Can I open a local Simulink MATLAB function block's code in the MATLAB editor via some command? For example, let us say I have a Simulink model named mainModel.slx. In it, there is a MATLAB function block named localFunction. This is not defined in…
Smartskaft2
  • 319
  • 1
  • 10
3
votes
2 answers

Call C function in matlab-simulink/stateflow

I created a C function in test.c #include int Test() { FILE * fp = fopen("C:\\workspace\\test.txt", "rw"); fprintf(fp, "test hello world"); fclose(fp); return 10; } And I defined a state in stateflow of simulink. I used…
user1192878
  • 684
  • 1
  • 7
  • 19
2
votes
1 answer

Simulink find() does not follow resolved links

I have a Simulink model "mod" with a Subsystem "link" in it, which is actually an active (i.e. "resolved") library link. Inside this linked Subsystem there is a Stateflow Chart "chart". In Simulink I can search for the Stateflow Chart like…
wls
  • 446
  • 1
  • 8
  • 20
2
votes
0 answers

Error in stateflow

I have a problem, when I am running my model. The error is: Error reported by S-function 'sf_sfun' in 'duo/Subsystem2/Genset1/Primover and generator/Electrical system/ SFunction ': Stateflow Suppress Error. failed assertion in…
Fanourako
  • 21
  • 1
  • 5
2
votes
2 answers

Test for compatibility in Matlab

I'm working with an open source Matlab toolbox which, according to its creators, is compatible for versions of Matlab over 7.6, i.e., R2008a. I tried to run it in R2011b and it threw the exception: Undefined variable "Simulink" or class…
2
votes
1 answer

My simple Stateflow model shows error

I'm almost new to Simulink and Stateflow. I am trying to model some simple state machines. But when trying to run the model, it shows errors (on the main Matlab screen). Warning: Input port 1 of 'sample/If' is not connected. Warning: Output port 1…
user1196937
2
votes
2 answers

Setting Events in Matlab/Simulink Stateflow

How can I set an event in a Simulink Stateflow (statechart) based on some value. What I mean is this. I have a variable called "choice". This "choice" comes in as an input from a simulink block.The value of choice is between 1 and 4. So all I want…
GuiccoPiano
  • 126
  • 1
  • 4
  • 12
1
vote
1 answer

MutableStateFlow events being overwritten

In MyViewModel a MutableStateFlow is used to transmit events to the fragment. When the value of the MutableStateFlow is changed the earlier values are being overwritten inside the coroutine. So never received by fragment. internal class…
Lakshman Chilukuri
  • 1,007
  • 2
  • 11
  • 18
1
vote
1 answer

Build state machine with 2 variables

I am new with Modelica but I would like to build an easy state machine with 2 variables : The initial step is "off" (the variable Light_cabin==0) then if button_Evac == 1 (second variable) then go to step "on" and Light_Cabin == 1 if Button_Evac==0…
Eloise
  • 37
  • 4
1
vote
1 answer

How to resolve'updates persistent or state variables while computing outputs, therefore it cannot be used in an algebraic loop....' error with Charts

I have a Model with 2 charts created with code. My first chart is a test simulation which go to a TIMER EXPIRED state when TimerStatus = 1;. The error occurs with my timer chart : When I try to simulate I get the error…
Lucas
  • 187
  • 10
1
vote
1 answer

Close Stateflow editor programmatically

Is there a way to close (or hide) a Stateflow Editor programmatically? I could not find any hint about this in the documentation or the net. The only way I know of is to close the model entirely, but I do not want this, as a changed model might need…
wls
  • 446
  • 1
  • 8
  • 20
1
vote
1 answer

How can I extract the location of the Stateflow blocks in a given Simulink model?

I have a Simulink model and I would like to extract the location of the Stateflow blocks it contains. I am looking for a command inspired by this command that gives the total number of blocks. How could I do this or where can I find more…
Karlo
  • 1,420
  • 25
  • 44
1
vote
1 answer

Simulink/StateFlow error with my Clock

I created this state machine chart in Simulink using the StateFlow : There are two states (S1,S2), one of which (S1) has 3 nested parallel FSM , each one has 4 states (SS1, SS2, SS2, SS4) , I put a default state in all of the 3 FSMs (SS1), and in…
Sam Gomari
  • 593
  • 2
  • 11
  • 27
1
2 3 4 5 6