Different order Bessel function in each column of an array

1 visualización (últimos 30 días)
David
David el 18 de Mzo. de 2018
Comentada: David el 19 de Mzo. de 2018
Is there a way of calculating the array J, below, without using a loop?
X = 0:0.1:20;
J = zeros(5,201);
for i = 0:4
J(i+1,:) = besselj(i,X);
end

Respuesta aceptada

Steven Lord
Steven Lord el 19 de Mzo. de 2018
From the documentation, "If nu and Z are arrays of the same size, the result is also that size." Make arrays for nu and Z using meshgrid.
  1 comentario
David
David el 19 de Mzo. de 2018
Hi Steve,
Thank you for your reply.
Great suggestion.
For those interested, the code without the loop reads like:
X = 0:0.1:20;
nu = 0:4;
XX = repmat(X,[length(0:4),1]);
nuu = repmat(0:4,[length(X),1])';
JJ = besselj(nuu,XX);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by