how to solve this second differential equation mx”+cx’+kx+kx^3=f0cos(wt)(I am stuck)
What is wrong in my code?
function Xdot=num_for(t,X)
m=100; k=1000; c=160;
ze=c/(2*sqrt(k*m));
wn=sqrt(k/m);
w=5; F=160; f=F/m;
y0=[0.01;0.1];
y1=y0.^2;
f=[0; f*cos(w*t)];
A=[0 1;-wn*wn-k/m*y1 -2*ze*wn];
Xdot=A*X+f;
end
Tspan=[0 10];
y0=[0.01;0.1];
[t,y]=ode45(@num_for,Tspan,y0);
figure
plot(t,y(:,1))What is wrong in my code?
function Xdot=num_for(t,X)
m=100; k=1000; c=160;
ze=c/(2*sqrt(k*m));
wn=sqrt(k/m);
w=5; F=160; f=F/m;
y0=[0.01;0.1];
y1=y0.^2;
f=[0; f*cos(w*t)];
A=[0 1;-wn*wn-k/m*y1 -2*ze*wn];
Xdot=A*X+f;
end
Tspan=[0 10];
y0=[0.01;0.1];
[t,y]=ode45(@num_for,Tspan,y0);
figure
plot(t,y(:,1)) What is wrong in my code?
function Xdot=num_for(t,X)
m=100; k=1000; c=160;
ze=c/(2*sqrt(k*m));
wn=sqrt(k/m);
w=5; F=160; f=F/m;
y0=[0.01;0.1];
y1=y0.^2;
f=[0; f*cos(w*t)];
A=[0 1;-wn*wn-k/m*y1 -2*ze*wn];
Xdot=A*X+f;
end
Tspan=[0 10];
y0=[0.01;0.1];
[t,y]=ode45(@num_for,Tspan,y0);
figure
plot(t,y(:,1)) differential equations MATLAB Answers — New Questions