Problem with the plot of function besselj.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardo Boza Villar
am 18 Mai 2016
Beantwortet: Ricardo Boza Villar
am 19 Mai 2016
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':
0 Kommentare
Akzeptierte Antwort
Roger Stafford
am 18 Mai 2016
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.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!