yp = @(x) sin(x)/x;x = 1:0.2:10;y = zeros(size(x));nsize = 0.2;a = 1;b = a+nsize;y(1)=5;for i=2:length(y) y(i)=((yp(a)+3*yp((2*a+b)/3)+3*yp((a+2*b)/3)+yp(b))/8).*(b-a)+y(i-1); a = b; b = b+nsize;endD1 = y;figureplot(x,y)hold onplot(x,yp(x))
MATLAB: I have a figure window down below, I’m trying to plot both (x,y) and (x,yp) on the same graph, but only one line is showing up instead of two. I’m tried fixing it, but I can’t seem to figure it out. Any ideas? Thanks.
figuregraphplot
Best Answer