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

6 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
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 个评论
Sriram Narayanan
Sriram Narayanan 2015-4-24
编辑:MathWorks Support Team 2022-2-23
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 2015-6-19
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Stateflow 的更多信息

标签

尚未输入任何标签。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by