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/07/05 23:51:26
![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](/uploads/image/z/1750427-35-7.jpg?t=matlab%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%96%B9%E7%A8%8Bfunction+%5Bx%2Cx1%2Cx2%5D%3D+cal_roots%28+a%2Cb%2Cc+%29%25UNTITLED+Summary+of+this+function+goes+here%25+Detailed+explanation+goes+hereif+a%3D%3D0error%28%27a%3D0--Not+a+quadratic+equation%27%29%3Belseif+abs%28b%5E2-4%2Aa%2Ac%29%3E+a%3D1%3Bb%3D5%3Bc%3D6%3B%3E%3E+%5Bx%2Cx1%2Cx2%5D%3Dcal_roots%28a%2Cb%2Cc%29Er)
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)