Problem with the plot of function besselj.

3 次查看(过去 30 天)
I have this code:
nu=1;
whitebg('k')
x=0:1e-3:9;
for n=1:4
paso=1/2^(n-1);
y1=besselj(nu,x);
figure(n),close(n),figure(n)
hold on
plot(x,y1,'b')
h=1e-5;
yder1=(besselj(nu,2+h)-besselj(nu,2))/h;
yder2=(besselj(nu,8+h)-besselj(nu,8))/h;
nodos=2:paso:8;
yvalues=besselj(nu,nodos);
y2=spline(nodos,[0.009,yvalues,0.5588],x);
plot(x,y2,'r')
y3=spline(nodos,[yder1,yvalues,yder2],x);
plot(x,y3,'w')
y4=spline(nodos,yvalues,x);
plot(x,y4,'g')
y5=interp1(nodos,yvalues,x);
plot(x,y5,'c')
grid
title('Bessel function for nu=1')
xlabel('Eje x')
ylabel('Eje y')
legend('Besselj','Spline sujeto mal','Spline sujeto bien',...
'Spline not-a-knot','Interp1','location','best')
end
But I don't know why the graphs of the function 'besselj' seem to decrease with every iteration. I would like the function 'besselj' to always display the same plot, that's why the variable 'nu' is constant in my script.
Here's the link to function 'besselj':

采纳的回答

Roger Stafford
Roger Stafford 2016-5-18
As can be seen on the left side of your graphs, the scaling in the vertical “Eje y” axis is changing. The bessel curves are not really changing. It is the red spline that is getting worse each time. You should use a constant scaling factor in your plotting to see what is actually happening.

更多回答(1 个)

Ricardo Boza Villar
Thank you

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by