问题描述:用Mathematica写程序,如果调用Solve[ ]出现某种异常,则中断计算,返回错误信息。

代码实现:

sol = Check[Solve[EQ, vars],
         Print["The number of variables is greater than the number of equations."];
         Abort[],Solve::svars];
If[Length[sol]==0,
      Print["There is no solution."];
      Abort[]
];
说明:如果Solve求解中出现 Solve::svars 的错误,则打印警告,用Abort终止计算;否则检查是否是无解。
posted on 2012-11-16 15:31  seventhsaint  阅读(366)  评论(0编辑  收藏  举报