필터 지우기
필터 지우기

What does "Equation is not a function of any variables. Each equation must be a function of at least one variable." mean?

조회 수: 3 (최근 30일)
Hello,
I am trying to modify inductor element from Simscape library. I want to change the inductance depending on the current flowing through. I wrote the following piece of code:
component inductor < foundation.electrical.branch
parameters
l = { 1e-6, 'H' }; % Inductance
i0 = { 0, 'A' }; % Initial current
r = { 0, 'Ohm' }; % Series resistance
g = { 1e-9, '1/Ohm' }; % Parallel conductance
end
variables
i_L = { 0, 'A' }; % Internal variable for current through inductor term
end
function setup
if l <= 0
pm_error('simscape:GreaterThanZero','Inductance')
end
if g < 0
pm_error('simscape:GreaterThanOrEqualToZero','Parallel conductance')
end
if g == {inf, '1/Ohm'}
pm_error('simscape:LessThan','Parallel conductance','inf')
end
if r < 0
pm_error('simscape:GreaterThanOrEqualToZero','Series resistance')
end
if r == {inf, 'Ohm'}
pm_error('simscape:LessThan','Series resistance','inf')
end
i_L = i0; % Assign initial current
end
equations
if i_L > { 10, 'A'}
l == 0.5 * l + {0, 'H'} * i_L / { 1, 'A' };
else
l == l + {0, 'H'} * i_L / { 1, 'A' };
end
v == i_L*r + l*i_L.der;
i == v*g + i_L;
end
end
And when I try to build a model, I get an error:
>> ssc_ build electrical
Generating 'electrical_lib.mdl' in the current directory 'c:\Michal\MATLAB Simulations\Thermal simulations' ...
??? Failed to generate 'electrical_lib'
Caused by:
Error using ==> inductor>equations at 33
Equation is not a function of any variables. Each equation must be a function of at least one variable.
Could you please tell me what does it mean, and what should I do to implement this feature.
Thank you in advance for any help you can offer.
Best regards,
Michal

답변 (1개)

Sabin
Sabin 2023년 2월 4일
The problem is in the if statement. In both branches you have '{0, 'H'} * i_L' which means that i_L is eliminated. As 'l' is a parameter it means there is no variable left in the equations.
In latest releases the code would build but will not simulate as the number of equations exceed number of variables.
If the goal is to modify the inductance probably best to use an intermediate, something like:
intermediates
l_new = if (condition), ... else ... end;
end

카테고리

Help CenterFile Exchange에서 Magnetic Elements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by