Polynominal approximation, least squares fit & Bessel function
Hi all,
As Bessel functions are not supported in Max/MSP I have to do a polynominal approximation...
I'm using this webpage: //oak.ucc.nau.edu/jws8/dpgraph/drumheads.html as a resource.
The approximation is p(r) = rm (1 - r2) (a + b r2 + c r4 ) where 0 < r < 1. It is an approximation for Jm(km,n r).
Apparently I have to do a "least squares fit" for a, b and c.
Where m = 2, n = 1 and K = 5.135 the author of the webpage gets a = 3.03 and b = -2.45. However the values I get are alot smaller, they are: a = -0.042855 and b = 0.065353.
The code I have written is below:
function [p]=calcPolyApproximation(m,K)
%n = order, K=m'th zero of the n'th order bessel function
bessel = besselj(m,(0:.01:1).*K);
[p,s] = polyfit((0:.01:1).*K,bessel,3);
z = polyval(p,(0:0.01:1).*K);
figure;plot(bessel,'*');
hold on;plot(z,'g');
Any help would be appreciated,
Carl.
Btw. I am very new to Matlab so sensitive with me