以创建一个解方程根的函数为例
x1 x2 为输出结果 a b c 为输入的参数
function [x1 x2]=equation_solve(a,b,c)
delt =b*b -4*a*c
if delt <0
'there is no answer!'
elseif delt==0
'there is only one answer'
x1=(-a+sqrt(delt))/2;
ans=x1;
else
'there has two answers'
x1=(-a+sqrt(delt))/2;
x2=(-a-sqrt(delt))/2;
ans=[x1 x2]
end