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

2 views (last 30 days)
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 Comment
M
M on 31 Oct 2017
This will not answer your question, but why are you defining syms t and then redefining t = 0:pi/100:2*pi ?

Sign in to comment.

Accepted Answer

Birdman
Birdman on 31 Oct 2017
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 Comments
Birdman
Birdman on 31 Oct 2017
Edited: Birdman on 31 Oct 2017
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.

Sign in to comment.

More Answers (1)

Matheus Marchiori
Matheus Marchiori on 9 Apr 2019
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