How to plot a sum with Bessel function in MATLAB?

13 visualizaciones (últimos 30 días)
Sergio Manzetti
Sergio Manzetti el 11 de Jun. de 2021
Respondida: Arnav el 25 de Nov. de 2024 a las 3:13
Hi, I am trying to plot the given function in Cartesian form,
Here I am to analyze the case of N=5, but when:
syms k phi n
z = 0:0.1:20;
J = zeros(5,201);
for i = 0:4
J(i+1,:) = besselj(i,z);
end
F1 = symsum(i.^(-n).*exp(i.*n.*phi).*J(5),k,-5,5);
I get a bunch of complex numbers, such as:
(82822462903397921*exp(4*n*phi))/(288230376151711744*4^n), -(73243657325038871*exp(4*n*phi))/(144115188075855872*4^n), -(52092056568810841*exp(4*n*phi))/(72057594037927936*4^n), -(4186064380238411*exp(4*n*phi))/(4503599627370496*4^n), -(40571731930933357*exp(4*n*phi))/(36028797018963968*4^n), -(5904078563759365*exp(4*n*phi))/(4503599627370496*4^n), -(13353078107853693*exp(4*n*phi))/(9007199254740992*4^n), -(59056575756875059*exp(4*n*phi))/(36028797018963968*4^n), -(64116376916153287*exp(4*n*phi))/(36028797018963968*4^n), -(68548273909920013*exp(4*n*phi))/(36028797018963968*4^n), -(36157402409718161*exp(4*n*phi))/(18014398509481984*4^n), -(75384812178058713*exp(4*n*phi))/(36028797018963968*4^n), -(77733708286557323*exp(4*n*phi))/(36028797018963968*4^n), -(79343679107811415*exp(4*n*phi))/(36028797018963968*4^n), -(40101912476022001*exp(4*n*phi))/(18014398509481984*4^n), -(20077559188965487*exp(4*n*phi))/(9007199254740992*4^n), -(79666007361392551*exp(4*n*phi))/(36028797018963968*4^n), -(78281177810055121*exp(4*n*phi))/(36028797018963968*4^n), -(38086309636606341*exp(4*n*phi))/(18014398509481984*4^n), -(73363851843391021*exp(4*n*phi))/(36028797018963968*4^n), -(34942400999611347*exp(4*n*phi))/(18014398509481984*4^n), -(65771501129227377*exp(4*n*phi))/(36028797018963968*4^n), -(30532864024275349*exp(4*n*phi))/(18014398509481984*4^n), -(436051554403795*exp(4*n*phi))/(281474976710656*4^n), -(50070108828077547*exp(4*n*phi))/(36028797018963968*4^n), -(43888628481747093*exp(4*n*phi))/(36028797018963968*4^n), -(74660724752913079*exp(4*n*phi))/(72057594037927936*4^n), -(30458772050598177*exp(4*n*phi))/(36028797018963968*4^n), -(46679941663105311*exp(4*n*phi))/(72057594037927936*4^n), -(64168382019089909*exp(4*n*phi))/(144115188075855872*4^n), -(8634660895872011*exp(4*n*phi))/(36028797018963968*4^n), -(1187903462638233*exp(4*n*phi))/(36028797018963968*4^n), (49823039306326275*exp(4*n*phi))/(288230376151711744*4^n), (54171966844352445*exp(4*n*phi))/(144115188075855872*4^n), (41377971864819623*exp(4*n*phi))/(72057594037927936*4^n), (3449913315497935*exp(4*n*phi))/(4503599627370496*4^n), (68419812172008385*exp(4*n*phi))/(72057594037927936*4^n), (40459839088567855*exp(4*n*phi))/(36028797018963968*4^n), (46291824070107649*exp(4*n*phi))/(36028797018963968*4^n), (12913192398877243*exp(4*n*phi))/(9007199254740992*4^n), (56494259104301733*exp(4*n*phi))/(36028797018963968*4^n), (30386495088826173*exp(4*n*phi))/(18014398509481984*4^n), (32225582096491003*exp(4*n*phi))/(18014398509481984*4^n), (67496822812660461*exp(4*n*phi))/(36028797018963968*4^n), (69884128263789081*exp(4*n*phi))/(36028797018963968*4^n), (71593584904701805*exp(4*n*phi))/(36028797018963968*4^n), (72612200135290057*exp(4*n*phi))/(36028797018963968*4^n), (18233395821812105*exp(4*n*phi))/(9007199254740992*4^n), (72557981721283773*exp(4*n*phi))/(36028797018963968*4^n), (71492253955601633*exp(4*n*phi))/(36028797018963968*4^n), (69749780247864651*exp(4*n*phi))/(36028797018963968*4^n), (8418788955703313*exp(4*n*phi))/(4503599627370496*4^n), (64319759102317191*exp(4*n*phi))/(36028797018963968*4^n), (7586240602709263*exp(4*n*phi))/(4503599627370496*4^n), (56498178537697919*exp(4*n*phi))/(36028797018963968*4^n), (51787081954593689*exp(4*n*phi))/(36028797018963968*4^n)]
I would like to plot it instead, but in polar plot. How do I do that?
Thanks
  1 comentario
Hans Scharler
Hans Scharler el 1 de Oct. de 2021
I am trying to bring this question to someone's attention. I will update soon.

Iniciar sesión para comentar.

Respuestas (1)

Arnav
Arnav el 25 de Nov. de 2024 a las 3:13
It appears that the function you are using is incorrect. The correct function is
This can be written as:
syms r phi n x y
u0 = symsum(1i^(-n) * besselj(n, r) * exp(1i*n*phi), n, -5, 5);
To convert this to a cartesian form, you can apply the polar to cartesian transformation using subs function as shown:
u0_cartesian = subs(u0, {r, phi}, {sqrt(x^2 + y^2), atan2(y, x)});
Since this is a complex valued function, we can plot its magnitude as a surface plot:
% Convert the symbolic expression to a MATLAB function
u0_cartesian_func = matlabFunction(u0_cartesian, 'Vars', [x, y]);
% Create a grid of x and y values
[x_vals, y_vals] = meshgrid(linspace(-10, 10, 200), linspace(-10, 10, 200));
% Evaluate the function over the grid
z_vals_abs = abs(u0_cartesian_func(x_vals, y_vals));
surf(x_vals, y_vals, z_vals_abs, 'EdgeColor', 'none'); % plot
You can learn more about the functions used in the following documentation links:

Categorías

Más información sobre Bessel functions en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by