I have 9 equations with a time dependent coefficient g
% MY M file
function dy =tarak(t,y)
G= 3.16;
g = 0.1*exp(-((t-200)/90).^2);
dy=zeros(9,1);
dy(1)=-2*2*y(1)+2*G*y(5)+2*g*y(7);
dy(2)=2*y(1)-2*G*y(5);
dy(3)=2*y(1)-2*g*y(7);
dy(4)=-2*y(4)+g*y(9);
dy(5)=-2*y(5)+G*(y(2)-y(1))+g*y(8);
dy(6)=-2*y(6)-G*y(9);
dy(7)=-2*y(7)+g*(y(3)-y(1))+G*y(8);
dy(8)=-G*y(7)-g*y(5);
dy(9)=G*y(6)-g*y(4);
then in command window:
[T,Y] = ode45(@tarak,[0 ,500],[0 0 1 0 0 0 0 0 0])
where coefficient G = 3.16 and g = 0.1*exp(-((t-200)/90).^2) is a time dependent coefficient and time t = 0:500; Initial condition [0 0 1 0 0 0 0 0 0].
I'm getting WRONG negative values for output y(1), y(2). Can someone pls try to solve above eqns with ode45 so that i can compare the results.


