ssc_update
Update Simscape component files to use new syntax
Syntax
ssc_update namespace
Description
The ssc_update command runs a script that
updates the legacy component files containing across and through statements.
Upon encountering a Simscape™ component file written in the old
format, the script creates a backup copy of the file (),
removes the filename.ssc.bakthrough and across statements
from the setup section, replaces the through statements
with the corresponding branches section and adds
the equations equivalent to the across statements
to the equations section of the file.
ssc_update
updates all the legacy component files located in the namespace. The argument,
namespace, must be a top-level namespace
name. namespace
Note
The namespace folder name begins with a leading + character, whereas
the argument to ssc_update must omit the +
character.
If you run the ssc_update command from inside the namespace folder
structure, you can omit the argument.
Examples
For example, you have a custom namespace +MyCapacitors, which contains a
component file IdealCapacitor.ssc, written in the old format:
component IdealCapacitor
% Ideal Capacitor
% Models an ideal (lossless) capacitor.
nodes
p = foundation.electrical.electrical; % +:top
n = foundation.electrical.electrical; % -:bottom
end
parameters
C = { 1, 'F' }; % Capacitance
V0 = { 0, 'V' }; % Initial voltage
end
variables
i = { 0, 'A' }; % Current through variable
v = { 0, 'V' }; % Voltage across variable
end
function setup
if C <= 0
error( 'Capacitance must be greater than zero' )
end
through( i, p.i, n.i ); % Through variable i from node p to node n
across( v, p.v, n.v ); % Across variable v from p to n
v = V0;
end
equations
i == C*der(v); % Equation
end
endTo update the file to the new format, at the MATLAB® command prompt, type:
ssc_update MyCapacitors;
This command creates a backup copy of the component file, IdealCapacitor.ssc.bak,
in the same folder where the original file resides, and rewrites the IdealCapacitor.ssc file
as follows:
component IdealCapacitor
% Ideal Capacitor
% Models an ideal (lossless) capacitor.
nodes
p = foundation.electrical.electrical; % +:top
n = foundation.electrical.electrical; % -:bottom
end
parameters
C = { 1, 'F' }; % Capacitance
V0 = { 0, 'V' }; % Initial voltage
end
variables
i = { 0, 'A' }; % Current through variable
v = { 0, 'V' }; % Voltage across variable
end
function setup
if C <= 0
error( 'Capacitance must be greater than zero' )
end
v = V0;
end
branches
i : p.i -> n.i; % Through variable i from node p to node n
end
equations
v == p.v - n.v; % Across variable v from p to n
i == C*der(v); % Equation
end
endAs you can see, the original through statement
through( i, p.i, n.i ); % Through variable i from node p to node n
has been replaced with the branches section:
branches
i : p.i -> n.i; % Through variable i from node p to node n
endThe across statement
across( v, p.v, n.v ); % Across variable v from p to n
has been replaced with the equation
v == p.v - n.v; % Across variable v from p to nin the equations section.
The other two statements in the setup section
have been left unchanged.
Note
Starting in R2019a, using setup is not recommended.
Other constructs available in Simscape language let you achieve the same results without compromising run-time
capabilities. For more information, see setup is not recommended.
Version History
Introduced in R2014a