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')

采纳的回答

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
Hi Jack. Can you send the full script after this changes? Thank you!

Community Treasure Hunt

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

Start Hunting!

Translated by