plot 1st order bessel derivative

5 visualizaciones (últimos 30 días)
zamri
zamri el 31 de Jul. de 2012
Comentada: Md Rezaul Karim el 19 de Abr. de 2020
Hi all,
Can i ask if somebody can help me on why i got 'matrix dimension don't agree' thereby cannot get a plot for first order bessel derivative.
If i type 'diff(besselj(1,z),z)', i'd get 'besselj(0, z) - besselj(1, z)/z'
but then when i want to plot 'besselj(0, z) - besselj(1, z)/z' by typing:
format long
z = (0:1:100)';
a=besselj(0, z) - besselj(1, z)/z;
plot(z,a)
it'd give error as below:
??? Error using ==> minus
Matrix dimensions must agree.
Error in ==> Untitled at 4
a=besselj(0, z) - besselj(1, z)/z;
for some reason the second term gives 101x101 dimension which doesnt agree with the first term (101x1).

Respuesta aceptada

Matt Kindig
Matt Kindig el 31 de Jul. de 2012
I think you need to use element-wise division with the z:
a=besselj(0, z) - besselj(1, z)./z;
  1 comentario
Md Rezaul Karim
Md Rezaul Karim el 19 de Abr. de 2020
yes. cheack elementwise div or mul

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 31 de Jul. de 2012
besselj(1, z)/z is using the mrdivide operator ("/"), and so is the least-squares solution to X*z = besselj(1, z) . This will not be a vector.
If you want to construct the list of [besselj(1,K) / K] for K in 0 : 100, then you should use the rdivide arithmetic divide operator rather than the matrix divide operator:
besselj(1, z) ./ z
  1 comentario
zamri
zamri el 1 de Ag. de 2012
thanks Walter, u're brilliant.

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by