Solenoid - Integration of inductance L as a function of plunger position x

조회 수: 1 (최근 30일)
Goutham Sajja
Goutham Sajja 2021년 5월 9일
답변: Vimal Rathod 2021년 6월 22일
Hello All,
I am in the process of evaluating the value of inductance L at each step of the plunger position in a solenoid according to the differential equation:
Force = 0.5*i^2*dL/dx
The value of current is a constant at 8.75 A. The value of force F varies at each step of the plunger position. dL/dx data for each step of the plunger position is available from the manufacturer force-stroke data. I need to integrate dL/dx to get L as a function of x. I tried using the ode45 function.
Lo = 3.8184e-3; % initial value of inductance
i = 8.74; % current in ampere
x = plungerPosition; % plungerPosition (984x1 double) data imported from excel
[x,L] = ode45(@(x,L) F/0.5*i^2, x, L0); % F (984x1 double) data also imported from excel, force in newton
But I get the following error:
Error using odearguments (line 95)
@(X,L)F/0.5*I^2 returns a vector of length 984, but the length of initial conditions vector is 1. The vector returned by
@(X,L)F/0.5*I^2 and the initial conditions vector must have the same number of elements.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in IntegrationofdL (line 4)
[x,L] = ode45(@(x,L) F/0.5*i^2, x, L0);
Can you please help me how I can solve this problem?
Thanks and Regards,
Goutham Sajja
  댓글 수: 1
Goutham Sajja
Goutham Sajja 2021년 5월 16일
Dear All,
A little update to the previous query. I modified the ode45 code to obtain the value of inductance for each changing of the plunger position x.
L0 = 3.8184e-3; % initial value of inductance
i = 8.75; % current in ampere
x = plungerPosition;
for j = 1:numel(F)
[x,L] = ode45(@eval, x, L0,[],F(j)); % F is the force at each plunger position
end
function dLdx = eval(x,F,i)
dLdx = (F/0.5*i^2); % equation is dL/dx = F/0.5*i^2
end
With this code, I get the value of inductance L for each plunger position x.
Could you please tell me if the code that I have written is correct?
Thanks and Regards,
Goutham Sajja

댓글을 달려면 로그인하십시오.

답변 (1개)

Vimal Rathod
Vimal Rathod 2021년 6월 22일
Hi Goutham,
Few things I would like to point out are, you seem to be passing a lot of arguments to the ode45 function call which might not work. Also, "eval" is matlab defined function which already exists, so I would suggest you to use some other name say "eval1". Make sure to define function in a different .m file. I have added a way to store the L values when returned from ode45 in a cell array.
Have a look at the following snippet, hopefully it helps.
L0 = 3.8184e-3; % initial value of inductance
i = 8.75; % current in ampere
x = plungerPosition;
Lval = {};
for j = 1:numel(F)
[x,L] = ode45(@(x,L)eval1(x, F(j), i), x, L0); % F is the force at each plunger position
Lval{end+1} = L;
end
% Below lines should be in a different file named "eval1.m"
function dLdx = eval1(x,F,i)
dLdx = (F/0.5*i^2); % equation is dL/dx = F/0.5*i^2
end
Refer to the following document for more examples on ode45

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by