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.

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 chart
ch = rt.find('-isa','Stateflow.Chart');

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

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

% Add a default transition to state A
dtA = Stateflow.Transition(ch);
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(ch);
d1.Scope = 'Input';
d1.Name = 'in1';

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

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

Here is the resulting chart:

Stateflow chart with two states.

Introduced before R2006a