matlab一元二次方程
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/14 06:55:02
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".
>>
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".
>>
正确的程序
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)
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)