fsolve stopped because of relative size of current step
조회 수: 13 (최근 30일)
이전 댓글 표시
I am trying to solve an equation using fsolve and I am getting the following error-
"fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance, but the vector of function values
is not near zero as measured by the default value of the function tolerance."
I am getting "No solution" even when I know that I should be getting a solution for all real values of psi. Can someone help me figure out what I need to change to get solutions.
syms y
psi = 0.1515;
r = 0.3;
a = r;
vf = [5 0];
m = 1;
x = linspace(-10*r,10*r);
x0 = ones(1,size(x,2));
opts = optimoptions(@fsolve,'Algorithm', 'levenberg-marquardt');
y = fsolve(@(y_val)solve_y(y_val,a,vf,x,psi,m),x0,opts);
% function solve_y
function F = solve_y(y_val,a,vf,x,psi,m)
y = y_val;
F = psi./norm(vf) - y - m*atan2(y,x+a) - m*atan2(y,x-a);
end
댓글 수: 2
Alan Weiss
2020년 6월 2일
I'm not at all sure that I understand what you are doing. Are you trying to solve for a bunch of scalar roots all at once, or is your objective really vector-valued? Why do you have a syms y call at the start of your script?
Alan Weiss
MATLAB mathematical toolbox documentation
답변 (1개)
darova
2020년 6월 14일
use for loop
syms y
psi = 0.1515;
r = 0.3;
a = r;
vf = [5 0];
m = 1;
x = linspace(-10*r,10*r);
x0 = ones(1,size(x,2));
F = @(y,x) psi./norm(vf) - y - m*atan2(y,x+a) - m*atan2(y,x-a);
opts = optimoptions(@fsolve,'Algorithm', 'levenberg-marquardt');
for i = 1:length(x)
y0 = fsolve(@(y)F(y,x(i)),x(i));
line(x(i),y,'markerk','*')
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!