I need to solve the equation y''+(1/x)y'-(1/x^2)y=0 with the initial conditions y(1)=0, y'(1)=0.01 usig ode45. I also have to plot the exact solution. When I run the code it plots the exact solution, but does not plot the numerical solution. Why is it not plotting?
function Untitled2clc;clear all;clf%Enter initial condition matrix
yo=[0,0.01];[x,y]=ode45(@DE2,(0:0.1:5),[);plot(x,y(:,1),'k-','Linewidth',1.5)xlabel('r'),ylabel('u'),grid ontitle('Numerical Solution of u(r)""+1/u(r)"-1/u(r)^2=0')hold on% Plot Exact Solution
X=0:.5:5;Y=-.002.*X+0.012./X;plot(X,Y,'or','markerfacecolor','r')legend('Numerical Solution','Exact Solution')function dydx=DE2(x,y)%Computes Derivatives of Each Equation
dydx=[y(2);((-1/x)*y(2)+(1/x^2)*y(1))];
Best Answer