Loren on the Art of MATLAB

Turn ideas into MATLAB

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Stateflow Charts Come to MATLAB! 6

Posted by Loren Shure,

I have been a little bit slow in announcing some of the coolest new features/products in the most recent release, R2019a. Why should you even care? What does Stateflow do? It allows you show the logic behind the work you are doing. You may say "I can already do that in MATLAB with if/else statements, switch/case statements, etc. And you can. But as you add extra conditions, the nesting of code and at least my ability to fully comprehend it can create a lot of mental overhead and burden. With state charts, you can encapsulate extra condition behavior without quite some much clutter, and yet high clarity.

You can get a quick idea from this picture, showing how to design the system of a lamp with the option to have the light blinking at different rates.

Guy beat me to the punch announcing Stateflow charts for MATLAB. Rather than replicate his wonderful post, I do want to encourage you to read about it. I also encourage you to watch a small video which, I hope, will give you some ideas.

One of the main MATLAB applications we see state charts helping with include the logic that controls Apps. I am quite sure there are others? Do have see a place in your workflow that a state chart can help with? Let me know here.


Get the MATLAB code

Published with MATLAB® R2019a

6 CommentsOldest to Newest

Green replied on : 1 of 6
Hi Loren! What is the file format used by Matlab to store these diagrams? Is it still possible de store the code in a plain-text format, so that it will be compatible with any external program (text editor, search engines, source control, etc.)? This was our principal obstacle to use AppDesigner and LiveScripts -- with all respect to MathWorks engineers, we can not afford loosing all external tools.
Gareth Thomas replied on : 2 of 6
This is really awesome. I really think that this is very powerful, however, the true power would come from leveraging the automatic test generation that MathWorks has for Stateflow diagrams to reach 100% coverage for Apps. It would be even cooler if the automatic test generation could optionally use the Unit Testing Framework for Apps -> I can't wait for R2019b:)
@Green- These files are saved in a special format and are not plain text.
@Gareth-
Glad you like :-)
@Kathleen- Have you looked at/tried Projects yet? I like them quite a bit, though I often do projects so small that I don't need them (one file!)... --loren
Steve Lord replied on : 5 of 6
@Green - FYI as of release R2016b you can configure your source control system to use the MATLAB Comparison Tool to diff and merge binary files like .mlx, .mat, .slx, or .mdl files. See the instructions in the documentation. I don't think the instructions have changed significantly (or at all) in the past couple releases, but if you're using an older release search for "external diff" in your locally installed documentation and you should find the equivalent page for your release if you want to be certain.

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide