54 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

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

Sebastian Castro
on 10 Sep 2015

No problem... also, if you want to make a quadratic spring, you may want the equation to handle the sign of the deformation:

f == k*x*abs(x);

- Sebastian

Sign in to comment.

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)

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/241630-error-compiling-simscape-network-for-model-number-of-variables-exceeds-number-of-equations#comment_470205

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/241630-error-compiling-simscape-network-for-model-number-of-variables-exceeds-number-of-equations#comment_470205

Sign in to comment.