?? quadroot.m
字號(hào):
function r = quadroot(a,b,c)
% quadroot Roots of quadratic equation and demo of keyboard command
%
% Synopsis: r = quadroot(a,b,c)
%
% Input: a,b,c = coefficients of a*x^2 + b*x + c = 0
%
% Output: r = column vector containing the real or complex roots
% See Chapter 4, Unavoidable Errors in Computing, for a discussion
% of the formula for r(1) and r(2)
d = b^2 - 4*a*c;
if d<0
fprintf('Warning in function QUADROOT:\n');
fprintf('\tNegative discriminant\n\tType "return" to continue\n');
keyboard;
end
q = -0.5*( b + sign(b)*sqrt(b^2 - 4*a*c) );
r = [q/a; c/q]; % store roots in a column vector
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -