필터 지우기
필터 지우기

Im trying to model a two coil (AC) wireless power transfer. Could anyone help me with my code? (Solving differential equations).

조회 수: 4 (최근 30일)
Im trying to solve a two coil power transfer circuit on Matlab using AC supply. Can anyone help me? This is what i have done so far:
Im getting an error in line 17.
syms I_1(t) I_2(t)
syms t
w=4;
t=0:pi/100:2*pi; %this creates a vector of values for t, from 0 to 2*pi in pi/100 increments.
y=sin(w*t); %takes sin of w * all the values in the t vector plot(t,y)
V_0 = y; %maximum voltage
R_1 = 10; %resistor 1
R_2 = 20; %resistor 2
L_1 = 0.055; %inductor 2
L_2 = 0.075; %inductor 2
k = 0.75; %coupling coefficient
M_12 = k*sqrt(L_1*L_2); %caculating mutual inductance
ode1 = diff(I_1) == (V_0- (R_1*I_1)+(M_12*I_2))/L_1;
ode2 = diff(I_2) == ((R_2*-I_2)-(M_12*I_1))/L_2;
odes = [ode1; ode2];
S = dsolve(odes);
I_1Sol(t) = S.I_1;
I_2Sol(t) = S.I_2;
[I_1Sol(t), I_2Sol(t)] = dsolve(odes);
cond1 = I_1(0) == 0;
cond2 = I_2(0) == 1;
conds = [cond1; cond2];
[I_1Sol(t), I_2Sol(t)] = dsolve(odes,conds);
fplot(I_1Sol)
hold on
fplot(I_2Sol)
grid on
legend('I_1Sol','I_2Sol','Location','best')
  댓글 수: 1
M
M 2017년 10월 31일
This will not answer your question, but why are you defining syms t and then redefining t = 0:pi/100:2*pi ?

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

채택된 답변

Birdman
Birdman 2017년 10월 31일
Your mistake is to define t vector numerically before solving differential equations. If you do so, the solver tries to differentiate the function with repsect to 0 and as a result, gives an error. To get rid of this situation, you need to define t vector after the line
[I_1Sol(t), I_2Sol(t)] = dsolve(odes,conds);
Since t is a symbolic variable, it will be better if you insert numerical values as:
t=subs(t,0:pi/100:2*pi)
  댓글 수: 2
Jack Levy
Jack Levy 2017년 10월 31일
Hi,
Thank you so much for helping me.
I am trying to get a sine wave for I_1 then a smaller sine wave for I_2.
Do you think there is anything else wrong?
Birdman
Birdman 2017년 10월 31일
편집: Birdman 2017년 10월 31일
When I substitute t with your vector, elements of I_1 and I_2 becomes NaN. Maybe you should change your initial conditions or check your ode equations.
By the way, if the answer helped you, you can accept the answer so that other people having the same problem will know there is a working solution.

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

추가 답변 (1개)

Matheus Marchiori
Matheus Marchiori 2019년 4월 9일
Hi Jack. Can you send the full script after this changes? Thank you!

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by