Error: "Number of variables exceeds number of equations." Probably a mistake in my code, but where?
이전 댓글 표시
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
답변 (2개)
Ryan G
2013년 3월 15일
0 개 추천
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.
댓글 수: 6
Ryan G
2013년 3월 15일
Could you get rid of M_B and instead set out == directly?
Ryan G
2013년 3월 15일
by the way, I was able to successfully SSC_BUILD the code you pasted above in R2013a.
Ryan G
2013년 3월 18일
Have you tried working from an example first? It may make more sense to take an example, change it to match your equation (start with constants instead of variables) and build up to your final system with all required variables.
Matthias
2013년 3월 18일
Matthias
2013년 3월 18일
카테고리
도움말 센터 및 File Exchange에서 Brakes and Detents에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!