Hello, I'm quite new to MATLAB and I'm having a problem when trying to solve the next system of differential equations for the case when Dw and w1 vary with time.
For the case when w1 and Dw are constants the code works just fine with dsolve.
If I add the time dependent functions w1 and dw my code looks like:
T1 = 0.6;
T2 = 0.1;
gamma = 4258;
dt = 0.0001;
Tp = 0.008;
Ns = Tp/dt;
B1 = 20;
f = 1200;
w1 = @(t) B1*sech((pi*f/mu)*(t-Tp));
dw = @(t) pi*f*tanh((pi*f/mu)*(t-Tp));
syms x(t) y(t) z(t)
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];
cond = [x(0) == 0, y(0) == 0, z(0) == 1];
[xSol(t),ySol(t),zSol(t)] = dsolve(eqns,cond);
And I get the error:
Warning: Unable to find explicit solution.
> In dsolve (line 201)
Error using sym/subsindex (line 825)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
I also tried with ODE45 but I get a similar error. Apparently I am not using the correct syntax. I read all the mathlab helps I could find but I didn't find an answer useful for this case.
Thanks for your help.