I want Simscape parameter data in my workspace to plot them...

3 views (last 30 days)
**Hi
I can extract through and across variable data from Simscape but i want the parameter data in Matlab workspace as well. I do not know how to do that. For example : In the code below, my parameter is L1, L2 and I want them in the workspace as well for plotting.
Could anyone can help me?**
component mutual_inductor
% Mutual Inductor :2.0
% Models a mutual inductor. If winding 1 has voltage V1 across it and
% current I1 flowing into its + terminal, and winding 2 has voltage V2
% across it and current I2 flowing into its + terminal, then
%
% V1 = L1*dI1/dt + M*dI2/dt
%
% V2 = L2*dI2/dt + M*dI1/dt
%
% where parameters L1 and L2 are the winding self-inductances, and
% M is the mutual inductance. M is defined in terms of major radius, minor
% radius and number of poloidal turns with the equation
%
%M_Lt = meu_0*N_t*a^2/(2*R); M_pL = 0.2*M_Lt;
%M = N_t*M_pL
%So finally, M = 0.2*meu_o*(N_t^2/(2*R))
%
% The parameters Winding 1 initial current and Winding 2 initial current
% set the initial current through windings 1 and 2. Note that this value is
% not used if the solver configuration is set to Start simulation from
% steady state.
% Copyright 2005-2008 The MathWorks, Inc.
nodes
p1 = foundation.electrical.electrical; % +:left
n1 = foundation.electrical.electrical; % -:left
p2 = foundation.electrical.electrical; % +:right
n2 = foundation.electrical.electrical; % -:right
end
parameters
L1 = { 1, 'H' }; % Toroidal inductance
L2 = { 2, 'H' }; % Poloidal inductance
meu_0 = { 1.256637*10^-6, 'H/m' }; % Vacuum permeability
N_t = 48; % Number of toroidal coil turns
R = { 0.5, 'm' }; % Major radius
a = { 0.057, 'm' }; % Mior radius
i10 = { 0, 'A' }; % Winding 1 initial current
i20 = { 0, 'A' }; % Winding 2 initial current
end
variables
i1 = { 0, 'A' };
v1 = { 0, 'V' };
i2 = { 0, 'A' };
v2 = { 0, 'V' };
end
function setup
through( i1, p1.i, n1.i );
across( v1, p1.v, n1.v );
through( i2, p2.i, n2.i );
across( v2, p2.v, n2.v );
if R <= 0
pm_error('simscape:GreaterThanZero','Major radius R')
end
if a <= 0
pm_error('simscape:GreaterThanZero','Minor radius a')
end
if N_t <= 0
pm_error('simscape:GreaterThanZero','Number of toroidal coil turns N_t')
end
i1 = i10; % Initialize current for winding 1
i2 = i20; % Initialize current for winding 2
end
equations
v1 == L1*i1.der + ((meu_0*0.2*N_t^2*a^2)/(2*R))*i2.der;
v2 == L2*i2.der + ((meu_0*0.2*N_t^2*a^2)/(2*R))*i1.der;
end

Answers (1)

Lincoln Emilio Bowen Aguayo
If you plot a variable from you SimScape model, you have to put a sensor that measure what you want. If you want to get the voltages, you have an option:
Once you have your "Physical Signal", transfor to Simulink signal using the Block Parameter: "PS-Simulink Converter".And Finally, put at the end a scope, that will give your data.
For get the values from your ScopeData, you have to enter to the parameter on the scope and in the tab of "History" choose "Save data to workspace" and then name your variable.
At the end in your script you have to write something like this (an example):
model = 'Name of your simulink program'; sim(model); time = ScopeData(:,1); X1 = ScopeData(:,2);

Categories

Find more on Variable Initialization in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!