Error compiling Simscape network for model: Number of variables exceeds number of equations.

67 views (last 30 days)
I have modified copy of spring.ssc file from Simscape foundation->translational library, and tried to model simple system but I am getting the error."Number of variables exceeds number of equations", How to identify consistency of equations with variables from available model, and used .ssc files? Some insights I want. Even if you share link containing the information, it will be helpful.
Thanks in advance!
component nspring
% Non-linear Spring
% Behavior is force proportional to square of deformation
nodes
r = foundation.mechanical.translational.translational; % r:right
c = foundation.mechanical.translational.translational; % c:left
end
parameters
k = { 1, 'N/(m*m)' }; % Spring constant
end
variables
v = { 0, 'm/s' }; % Velocity
f = { 0, 'N' }; % Force
x = { 0, 'm' }; % Deformation
end
function setup
if k <= 0
error('k cannot be less than zero')
end
end
branches
f : r.f -> c.f;
end
equations
v == r.v-c.v;
f == k*x*x;
end
end
  1 Comment
lilly michel
lilly michel on 19 Jul 2017
When I use simulink to compile the battery model, the following problems always occur: Error compiling Simscape network for model ssc_lithium_cell_2RC_TEST. Caused by: Unable to compile the physical network. Bother me for a long time, hope to get your guidance

Sign in to comment.

Accepted Answer

Sebastian Castro
Sebastian Castro on 9 Sep 2015
Yep, you have 3 variables (force, deformation, velocity) but only 2 equations.
The missing one I believe is the one relating the deformation and velocity using the "der" keyword.
v == x.der;
- Sebastian

More Answers (1)

aymen
aymen on 21 Apr 2018

Hy i have the same error in the component of mass.

this is the code: nodes M = foundation.thermal.thermal; % :top end

parameters mass = { 1000, 'kg' };

    sp_heat = { 447, 'J/(kg*K)' };   % Specific heat
end

variables % Differential variables T = {value = {300, 'K'}}; % Temperature

    Q = { 0, 'J/s' }; % Heat flow
end

function setup %#simple % Parameter range checking if mass <= 0 pm_error('simscape:GreaterThanZero','Mass') end if sp_heat <= 0 pm_error('simscape:GreaterThanZero','Specific heat') end end

branches Q : M.Q -> *; end

equations T == M.T; Q == mass * sp_heat * T.der; assert(T>0, 'Temperature must be greater than absolute zero') end

end

and this is the error message

['HEV_SeriesParallel/Electrical/System Level/DC-DC Converter/Thermal Model/Thermal Mass']: Type mismatch for equation. The left hand side of the equation is {[1x1 double], 'C'} and the right hand side of the equation is {[1x1 double], 'K'}. T = {[1x1 double], 'C'} M.T = {[1x1 double], 'K'} In foundation.thermal.elements.mass (line 45)

Categories

Find more on Run-Time Parameters in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!