Different order Bessel function in each column of an array

조회 수: 2 (최근 30일)
David
David 2018년 3월 18일
댓글: David 2018년 3월 19일
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

채택된 답변

Steven Lord
Steven Lord 2018년 3월 19일
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
David
David 2018년 3월 19일
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);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bessel functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by