I am working on 1. I am having trouble coding the function so that I can use the ode45 function. This is what my code looks like :
function xp=F(t,x)xp=zeros(2,1); % since output must be a column vector
xp(2)=-(x(1)+(0*(x(1)^3)));xp(3)=-(x(1)+(0.1*(x(1)^3)));xp(4)=-(x(1)+(0.2*(x(1)^3)));xp(5)=-(x(1)+(0.4*(x(1)^3)));xp(6)=-(x(1)+(0.6*(x(1)^3)));xp(7)=-(x(1)+(0.8*(x(1)^3)));xp(8)=-(x(1)+(1.0*(x(1)^3)));
then in the command window I am inputting :
[t,x]=ode45('F',[0,20],[0,1]); plot(t,x(:,1))
I know I probably messed up the code . Any ideas?
Best Answer