ex1_9.m

来自「Programs for the book Advanced Engineeri」· M 代码 · 共 22 行

M
22
字号
function [x,Eflag] = quadrat(a,b,c)
%
% Function to solve the quadratic equation ax^2+bx+c=0
%
% CALL [x,Eflag]=quadrat(a,b,c)   
%
% INPUTS:  a, b, and c coefficients as real numbers
%
% OUTPUTS: x, a vector of the solutions as real or complex numbers
%	   Eflag, error condition 
%		if a=b=0, Eflag=1 since x is not defined
%		otherwise Eflag=0
%
% ALGORITHM: The quadratic formula is used in the form
%		(1) x = -b/2a +/- sqrt(b^2-4ac)/2a, if a not = 0;
%		(2) x = -c/b, if a =0 and b not = 0.
% ________________________________
%
Eflag=0;	% Assume result is correct
% (Program statements start here)
%
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?