matlab一元二次方程function [x,x1,x2]= cal_roots( a,b,c )%UNTITLED Summary of this function goes here% Detailed explanation goes hereif a==0error('a=0--Not a quadratic equation');elseif abs(b^2-4*a*c)> a=1;b=5;c=6;>> [x,x1,x2]=cal_roots(a,b,c)Er
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 16:00:49
matlab一元二次方程function [x,x1,x2]= cal_roots( a,b,c )%UNTITLED Summary of this function goes here% Detailed explanation goes hereif a==0error('a=0--Not a quadratic equation');elseif abs(b^2-4*a*c)> a=1;b=5;c=6;>> [x,x1,x2]=cal_roots(a,b,c)Er
matlab一元二次方程
function [x,x1,x2]= cal_roots( a,b,c )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
if a==0
error('a=0--Not a quadratic equation');
elseif abs(b^2-4*a*c)> a=1;b=5;c=6;
>> [x,x1,x2]=cal_roots(a,b,c)
Error in cal_roots (line 4)
if a==0
Output argument "x" (and maybe others) not assigned during call to
"C:\Users\think\Documents\MATLAB\cal_roots.m>cal_roots".
>>
matlab一元二次方程function [x,x1,x2]= cal_roots( a,b,c )%UNTITLED Summary of this function goes here% Detailed explanation goes hereif a==0error('a=0--Not a quadratic equation');elseif abs(b^2-4*a*c)> a=1;b=5;c=6;>> [x,x1,x2]=cal_roots(a,b,c)Er
正确的程序
clc
clear
a=1;b=5;c=6;
[x1,x2]=cal_roots(a,b,c)
%%%%%%%%%%%%%%%%%
function [x1,x2]=cal_roots(a,b,c)%UNTITLED Summary of this function goes here% Detailed explanation goes herei
if a==0
error('a=0--Not a quadratic equation');
elseif abs(b^2-4*a*c)