matlab2023a中解方程

1、matlab中解方程的函数是solve

2、查看帮助:

  help solve

help solve
--- sym/solve 的帮助 ---

 sym/solve - Equations and systems solver
    This MATLAB function solves the equation eqn for the variable var.

    语法
      S = solve(eqn,var)
      S = solve(eqn,var,Name,Value)

      Y = solve(eqns,vars)
      Y = solve(eqns,vars,Name,Value)

      [y1,...,yN] = solve(eqns,vars)
      [y1,...,yN] = solve(eqns,vars,Name,Value)
      [y1,...,yN,parameters,conditions] = solve(eqns,vars,'ReturnConditions',true)

    输入参数
      eqn - Equation to solve
        symbolic expression | symbolic equation
      var - Variable for which you solve equation
        symbolic variable
      eqns - System of equations
        symbolic expressions | symbolic equations
      vars - Variables for which you solve an equation or system of
      equations
        symbolic vector | symbolic matrix

    名称-值参数
      Real - Flag for returning only real solutions
        false (默认值) | true
      ReturnConditions - Flag for returning parameters and conditions
        false (默认值) | true
      IgnoreAnalyticConstraints - Simplification rules applied to
      expressions and equations
        false (默认值) | true
      IgnoreProperties - Flag for returning solutions inconsistent with
      properties of variables
        false (默认值) | true
      MaxDegree - Maximum degree of polynomial equations for which solver
      uses explicit formulas
        2 (默认值) | positive integer smaller than 5
      PrincipalValue - Flag for returning one solution
        false (默认值) | true

    输出参数
      S - Solutions of equation
        symbolic array
      Y - Solutions of system of equations
        structure
      y1,...,yN - Solutions of system of equations
        symbolic variables
      parameters - Parameters in solution
        vector of generated parameters
      conditions - Conditions under which solutions are valid
        vector of symbolic expressions

    示例
      Solve Quadratic Equation
      Solve Polynomial and Return Real Solutions
      Numerically Solve Equations
      Solve Multivariate Equations and Assign Outputs to Structure
      Solve Inequalities
      Solve Multivariate Equations and Assign Outputs to Variables
      Use Parameters and Conditions to Refine Solution
      Shorten Result with Simplification Rules
      Ignore Assumptions on Variables
      Solve Polynomial Equations of High Degree
      Return One Solution

    另请参阅 dsolve, isolate, linsolve, root, subs, symvar, vpasolve,
      Solve Symbolic Equation

    已在 R2006a 之前的 Symbolic Math Toolbox 中引入
    sym/solve 的文档
    solve 的其他用法

3、点击示例下的

 Solve Quadratic Equation,打开

4、照着输入下,应该就差不多明白了,有一点注意,定义符号变量是syms,不是sym了:

syms x;
solve([x^3+6*x^2+8*x+15==0],[x])
 
ans =
 
                     -5
- (11^(1/2)*1i)/2 - 1/2
  (11^(1/2)*1i)/2 - 1/2

 

posted @ 2023-06-20 17:03  叕叒双又  阅读(209)  评论(0编辑  收藏  举报