MATLAB: How to plot a first order differential equation with singular point MATLABode45 Is there a way to plot a first or second order differential equation with singular point? Example equation: (1-y^2)*y" + 5*y' + 3*y = 0 Usually I get error message from ode about division by zero. Best Answer Save this file as odef.mfunction dx=odef(t,x)dx=zeros(2,1)dx(1)=x(2);dx(2)=(-5*x(2)-3*x(1))/(1-x(1)^2)Then call it%y'(0)=0.1 and y(0)=0.1 are initial conditionstspan=[0 10][t,y]=ode45(@odef,tspan,[0.1 ;0.1])plot(t,y) Related SolutionsMATLAB: System of differential equations Main programy0=[0 1];tspan=[0 10];[t,y]=ode45(@myeq,tspan,y0)save this function as myeq.mfunction dx=myeq(t,x)dx=zeros(2,1);dx(1)=x(1)-x(1)^3+x(2); dx(2)=3*x(1)-x(2) ; MATLAB: Solve a second order differential equation in matlab You can transform your equation d2y/dx2=.-5dy/dx-7y to get:y1=yy2=dy/dxdy1=dy/dx=y2dy2=d2y/d2x=-5dy/dx-7y=-5y2-7y1Create a file named myode.mfunction dy=myode(x,y)dy=[0;0]dy(1)=y(2)dy(2)=-5*y(2)-7*y(1)Then run these linesyin=[0 4 ] % initial valuestime=[0 5][x,y]=ode45(@myode,time,yin)plot(x,y) Related QuestionHow to solve the differential equation numerically by fourth order Runge-Kutta Method
Best Answer