필터 지우기
필터 지우기

solve Bassel function matlab

조회 수: 5 (최근 30일)
Carlos_conde
Carlos_conde 2017년 5월 17일
답변: Star Strider 2017년 5월 17일
I am trying to solve a Bessel function depending of a variable "x", for that reason I am using the fsolve command:
%%myfun
function F = myfun(x)
F = [1.5*(1-x)*besselj(0,x)-x*bessely(0,x)*(x.^2-1)];
%%main file
x0 = [0; 0];
[x,fval] = fsolve(@myfun,x0)
I do not understand what I am doing wrong.
Regards

답변 (2개)

John D'Errico
John D'Errico 2017년 5월 17일
myfun is a function of ONE variable, x. There is only ONE unknown, so x should be a scalar.
But if that is true, then why have you provided a VECTOR starting value in x0?

Star Strider
Star Strider 2017년 5월 17일
You need to (1.) vectorize every multiplication and division in your function, as well as the exponentiation, and (2.) start a a point close to (not at) 0 in order to avoid fsolve throwing a ‘Objective function is returning undefined values at initial point. FSOLVE cannot continue.’ error.
This works:
myfun = @(x) 1.5*(1-x).*besselj(0,x)-x.*bessely(0,x).*(x.^2-1);
x0 = [1; 1]*eps;
[x,fval] = fsolve(myfun,x0);

카테고리

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