plot 1st order bessel derivative

7 ビュー (過去 30 日間)
zamri
zamri 2012 年 7 月 31 日
コメント済み: Md Rezaul Karim 2020 年 4 月 19 日
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).

採用された回答

Matt Kindig
Matt Kindig 2012 年 7 月 31 日
I think you need to use element-wise division with the z:
a=besselj(0, z) - besselj(1, z)./z;
  1 件のコメント
Md Rezaul Karim
Md Rezaul Karim 2020 年 4 月 19 日
yes. cheack elementwise div or mul

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 7 月 31 日
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 件のコメント
zamri
zamri 2012 年 8 月 1 日
thanks Walter, u're brilliant.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBessel functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by