Error: "Number of variables exceeds number of equations." Probably a mistake in my code, but where?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, i try to program a simple Simscape-Block which calculates a braking moment for an output signal by using an external force and some parameters. When i try to run the model in the test environment, the error-message "Number of variables exceeds number of equations. Check for missing reference node." comes up. I'm pretty sure its a mistake in the code, but where? I already tried not to inlcude v = {0, ...) and across(v, ...), but that didnt change anything. The code is the following:
component Multi_Disc_Brake
nodes
R = foundation.mechanical.translational.translational; % R:left
C = foundation.mechanical.translational.translational; % C:right
end
parameters
n = {1, '1'}; % Number of rotating discs
r_i = {1, 'm'}; % Radii of inner discs
r_a = {2, 'm'}; % Radii of outer discs
my = {1, '1'}; % Friction coefficient
end
variables
f = {0, 'N'};
M_B = {0, 'N*m'};
r_m = {0, 'm'};
v = {0, 'm/s'};
end
outputs
out = {0, 'N*m'}; % M(t):right:top
end
function setup
if n <= 0
error ('Number of discs must be greater than zero');
end
if r_i <= 0
error ('Inner radii must be greater than zero');
end
if r_a <= 0
error ('Outer radii must be greater than zero');
end
if r_i >= r_a
error ('Inner radii has to be smaller than outer radii');
end
through (f, R.f, C.f);
across (v, R.v, C.v);
end
equations
let
r_m = (2/3)*((r_a^3 - r_i^3)/(r_a^2 - r_i^2)); % Centre radius
in
M_B == my*f*r_m*2*n; % Calculation of the braking moment
end
out == M_B;
end
end
Thank you in advance for your help!
Matt
0 comentarios
Respuestas (2)
Ryan G
el 15 de Mzo. de 2013
Sounds like you understand the basics of the error. Without digging to deep I see 4 variables and maybe 2 or 3 equations (I'm not sure how Simscape counts equations in let-in format). So at best you still have 1 more variable than equation.
That being said I don't see v utilized in the equations section nor do I see either of your nodes being used. In other words, right now I believe this would output a constant, which doesn't make sense for a Simscape component.
I might be missing something here, let me know if I'm wrong.
0 comentarios
Ver también
Categorías
Más información sobre Brakes and Detents en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!