Skip to Main Content Skip to Search
Product Documentation

sfsave - Save chart in current folder

Syntax

sfsave
sfsave('model_name')
sfsave('model_name','new_model_name')
sfsave('Defaults')

Description

sfsave saves the chart in the current model.

sfsave('model_name') saves the chart in the model called 'model_name'.

sfsave('model_name','new_model_name') saves the chart in 'model_name' to 'new_model_name'.

sfsave('Defaults') saves the settings of the current model as defaults. 'Defaults' is a literal string.

The model must be open and the current folder must be writable.

Examples

Develop a script to create a baseline chart and save it in a new model:

bdclose('all');

% Create an empty chart in a new model
sfnew;

% Get root object
rt = sfroot;

% Get model
m = rt.find('-isa','Simulink.BlockDiagram');

% Get chart
chart1 = m.find('-isa','Stateflow.Chart');

% Create two states, A and B, in the chart
sA = Stateflow.State(chart1);
sA.Name = 'A';
sA.Position = [50 50 100 60];
sB = Stateflow.State(chart1);
sB.Name = 'B';
sB.Position = [200 50 100 60];

% Add a transition from state A to state B
tAB = Stateflow.Transition(chart1);
tAB.Source = sA;
tAB.Destination = sB;
tAB.SourceOClock = 3;
tAB.DestinationOClock = 9;

% Add a default transition to state A
dtA = Stateflow.Transition(chart1);
dtA.Destination = sA;
dtA.DestinationOClock = 0;
x = sA.Position(1)+sA.Position(3)/2;
y = sA.Position(2)-30;
dtA.SourceEndPoint = [x y];

% Add an input in1
d1 = Stateflow.Data(chart1);
d1.Scope = 'Input';
d1.Name = 'in1';

% Add an output out1
d2 = Stateflow.Data(chart1);
d2.Scope = 'Output';
d2.Name = 'out1';

% Save the chart in a model called "NewModel"
% in current folder
sfsave('untitled','NewModel');

Here is the resulting model:

Here is the resulting chart:

See Also

find | sfclose | sfnew | sfopen | sfroot

Tutorials

How To

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS