Problem with the plot of function besselj.

조회 수: 4 (최근 30일)
Ricardo Boza Villar
Ricardo Boza Villar 2016년 5월 18일
답변: Ricardo Boza Villar 2016년 5월 19일
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
Ricardo Boza Villar 2016년 5월 19일
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