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 Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by