方程是:
其中a
和b
是常数并且都等于0.0130
这是我正在使用的代码:
% Solving the equation for zero.
f = @(theta) ((a+b).*theta)./((theta.^2)-(a.*b)) - tan(theta); % Notice the dots (.)
% Now plot it to get an idea of where the zeros are.
theta = 0:1:100;
for i=1:length(theta)
hold on
plot(theta(i),f(theta(i)),'-o') % Look for the zeros
end
% Now find the roots.
cnt = 1;
for ii = [0,2,50] % This vector has the guesses.
rt(cnt) = fzero(f,ii); % Pass each guess to FZERO.
cnt = cnt + 1;
end
这是我得到的错误:
??? Operands to the || and && operators must be convertible to
logical scalar values.
Error in ==> fzero at 323
elseif ~isfinite(fx) || ~isreal(fx)
Error in ==> HW4 at 52
rt(cnt) = fzero(f,ii); % Pass each guess to FZERO.
我想得到 \theta 的第一个解决方案。谢谢。