How can I print out all of the stateflow charts in my model?

16 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Feb 2013
The following code will iteratively walk through a model's Stateflow charts and use the PRINT command to print the associated figure windows.
The FIND_SYSTEM will look for all SubSystems that are a Stateflow type. Then those charts are made active and visible by the OPEN_SYSTEM command. Then they are saved to the current directory using the PRINT command. This example prints them as Windows EMF files, but the option can be changed to any supported format, as described in the documentation.
shh = get(0,'ShowHiddenHandles');
set(0,'ShowHiddenHandles','on')
Sub_sys = find_system(gcs,'FollowLinks','off','LookUnderMasks','off','SearchDepth',...
1,'blocktype','SubSystem')
for i =1:length(Sub_sys)
if(strcmp(get_param(Sub_sys{i},'Masktype'), 'Stateflow')== 1)
open_system(Sub_sys{i})
print([get_param(Sub_sys{i},'Name') '.emf'],'-dmeta');
close(gcf)
end
end
set(0,'showHiddenHandles',shh)
  2 Comments
Sriram Narayanan
Sriram Narayanan on 24 Apr 2015
Edited: MathWorks Support Team on 23 Feb 2022
In R2013a, you can mask a chart, Truth Table block, or State Transition Table block directly. In previous releases, you had to place the Stateflow block in a subsystem, and then mask that subsystem.
In R2013a, MATLAB scripts or functions that rely on the MaskType property of Stateflow blocks need to be updated. For example, get_param(handle_to_SF_block, 'MaskType') now returns an empty value instead of 'Stateflow'.
As a workaround, for backward compatibility, use FIND_SYSTEM functionality of MATLAB which returns all the Stateflow blocks:
find_system('MaskType','Stateflow')
However, as a better practice, use the Stateflow API instead. See “Overview of the Stateflow API” using the below link. Do not create masks with Mask Type "Stateflow", because it makes the behaviour unpredictable. Stateflow API is the best option here.
Sriram Narayanan
Sriram Narayanan on 19 Jun 2015
It is not possible to directly query just the transitions without truth table transitions currently. You would have to extract the transitions from the transarray object that you desire to use.

Sign in to comment.

More Answers (0)

Categories

Find more on Stateflow Programmatic Interface in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!