简单来说,solve函数可以进行以下情况的求解:
(1)等式:单/多变量+线性/非线性 ;(2)不等式
(是MATLAB doc solve的全部翻译,将常用部分标注彩色)
(唉,以后绝不这样干了)
语法
S = solve(eqn,var)example
S = solve(eqn,var,Name,Value)example
Y = solve(eqns,vars)
Y = solve(eqns,vars,Name,Value)example
[y1,...,yN] = solve(eqns,vars)example
[y1,...,yN] = solve(eqns,vars,Name,Value)
[y1,...,yN,parameters,conditions] = solve(eqns,vars,'ReturnConditions',true)example
Description
一些函数
vpa 设置数值的精度(有效数字位数、保留的小数点位数)
subs 符号替换(用数字来替换符号变量)
ezplot 简单地画出函数的图形/曲线(显函数fun(x)、隐函数fun2(x,y)=0)
isAlways 一个判断函数(返回logical 1,表示true)
pretty 漂亮地打印符号表达式(看起来是有分子分母的格式)
举例
1.%% 求解单变量方程
%-----例子1------
syms x
eqn=sin(x)==1;
solve(eqn,x)
%-----例子2------
syms x
eqn=sin(x)==1;
[solx,params,conds]=solve(eqn,x,'ReturnConditions',true)
%-----例子3---------------
%如果返回empty,则表明解不存在。如果返回empty+warning,则解可能存在,但是solve找不到
syms x
solve(3*x+2,3*x+1,x)
2.%% 求解多变量方程
%---例1-----------------
%为了避免求解方程时对符号参数产生混乱,需要指明一个等式中需要求解的变