System of differential equations with periodic function in each equation
1 view (last 30 days)
Show older comments
Rachel Kirkland
on 27 Jan 2020
Commented: Star Strider
on 27 Jan 2020
Hi, I was wondering if anyone could help explain why I am getting following plot
instead of something which looks more like this
Clearly I have more oscillations than expected.
I have the following two Matlab scripts:
function f=crimp(t,y,g1,g2,l1,l2,om,K1,K2)
f=zeros(3,1);
f(1)=g1-K1*y(1)*(((1+sin((pi*t)/6))/10)+y(3));
f(2)=g2-K2*y(2)*(((1+sin((pi*t)/6))/10)+y(3));
f(3)=(l1*y(1)+l2*y(2))*(((1+sin((pi*t)/6))/10)+y(3))-om*y(3);
and
g1=0.02;
g2=0.01;
K1=1;
K2=1;
l1=0.7;
l2=0.2;
om=0.2;
K=K2/K1;
A=1/10;
inp1=(K*g1)/(A*K+K*g1+g2);
inp2=g2/(A*K+K*g1+g2);
inB=(K*g1+g2)/K;
y0=[inp1 inp2 inB];
[t,y]=ode15s(@(t,y) crimp(t,y,g1,g2,l1,l2,om,K1,K2),[0 60],y0);
hold off
axis([0 60 0 0.25])
plot(t,y(:,1),'-blue',t,y(:,2),'-red',t,y(:,3),'-green')
I don't know where I am going wrong. I have tried to put in dots before operators in the differential equations f(1), f(2) and f(3).
Please can anyone help?
Thanks in advance
0 Comments
Accepted Answer
Star Strider
on 27 Jan 2020
There are obviously sin calls in ‘crimp’, so that explains the oscillations.
The real question is why you are not getting the decaying exponentials. I suspect the sin calls are actually supposed to be hyperbolic sine calls, using the sinh function instead. When I make that change, the plot comes close to matching the one you want.
The anonymous function version:
crimp = @(t,y,g1,g2,l1,l2,om,K1,K2) [g1-K1*y(1)*(((1+sinh((pi*t)/6))/10)+y(3)); g2-K2*y(2)*(((1+sinh((pi*t)/6))/10)+y(3)); (l1*y(1)+l2*y(2))*(((1+sinh((pi*t)/6))/10)+y(3))-om*y(3)];
for convenience.
2 Comments
Star Strider
on 27 Jan 2020
As always, my pleasure!
Errors in published papers are much more common than usually realised. I suspect many of have encountered irreproducable results.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!