How do I make a function from a symbolic expression in MATLAB?

前端 未结 4 1405
一个人的身影
一个人的身影 2021-01-05 06:59

How can I make a function from a symbolic expression? For example, I have the following:

syms beta
n1,n2,m,aa= Constants
u = sqrt(n2-beta^2);
w = sqrt(beta^2         


        
4条回答
  •  粉色の甜心
    2021-01-05 07:40

    If you're interested with just the answer for this specific equation, Try Wolfram Alpha, which will give you answers like:

    alt text http://www4c.wolframalpha.com/Calculate/MSP/MSP642199013hbefb463a9000051gi6f4heeebfa7f?MSPStoreType=image/gif&s=15

    If you want to solve this type of equation programatically, you probably need to use some software packages for symbolic algebra, like SymPy for python.

    quoting the official documentation:

    >>> from sympy import I, solve
    >>> from sympy.abc import x, y
    

    Solve a polynomial equation:

    >>> solve(x**4-1, x)
    [1, -1, -I, I]
    

    Solve a linear system:

    >>> solve((x+5*y-2, -3*x+6*y-15), x, y)
    {x: -3, y: 1}
    

提交回复
热议问题