As darova suggested, integrate it numerically. For some reason, ode45 does not like the anonymous functions and throws an ’Undefined function or variable’ error (although I¹ve used them successfully in other situations to create time-varying parameters in numerically-integrated differential equations), so it’s necessary to include them in the actual code:
T1 = 0.6;
T2 = 0.1;
gamma = 4258;
dt = 0.0001;
Tp = 0.008;
Ns = Tp/dt;
B1 = 20;
f = 1200;
mu=6;
syms x(t) y(t) z(t) dw(t) w1(t) t Y
dw(t) = pi*f*tanh((pi*f/mu)*(t-Tp));
w1(t) = 1*sech((pi*f/mu)*(t-Tp));
eqns = [diff(x(t),t) == -x(t)/T2 + dw(t)*y(t), diff(y(t),t) == -dw(t)*x(t) - y(t)/T2 + w1(t)*z(t),diff(z(t),t) == -w1(t)*y(t) - (z(t)-1)/T1];
[VF,Subs] = odeToVectorField(eqns)
odefcn = matlabFunction(VF, 'Vars',{t,Y})
tspan = [0 1];
ic = [0 0 1];
[T,XYZ] = ode45(@(t,Y)odefcn(t,Y), tspan, ic);
figure
for k = 1:size(XYZ,2)
subplot(size(XYZ,2),1,k)
plot(T,XYZ(:,k))
grid
title(string(Subs(k)))
end
This ran without error in R2020a.
Best Answer