function [x1 x2]=equationSolve(a,b,c) %[x1 x2] is return value %a,b,c are input parameters %calculate quadratic equation with one unknown delt=b*b-4*a*c; if delt<0 'no answer'; elseif delt==0 'only one answer'; x1=-a/2; else x1=(-a+sqrt(delt))/2; x2=(-a-sqrt(delt))/2; end保存为equationSolve.m,加入到matlab的path中,就可以直接用了。
原文地址:http://blog.csdn.net/chuchus/article/details/44727071