I'm trying to simplify an expression or equation symbolically and I get the same error every time. Undefined function or variable 'x'.

I'm trying to simplify an expression symbolically and I get the same error every time.
Undefined function or variable 'x'.
I'm even using the actual example matlab provides. Trying to just simplify the expression sin(x)^2 + cos(x)^2 I get the error everytime. I'm brand new...what am I missing.

 采纳的回答

What exactly is your command? It seems like you haven't told MATLAB what the value of x is. First, initialize a value for x and the carry on.
x = 0.5;
sin(x)^2 + cos(x)^2;

4 个评论

Wow I guess I'm trying to make it to complicated. I want to simplify a much more complicated expression to find some constants of integration and I was trying to stay away from that in order to solve them later. But I guess I can define them first and then go back and do some tinkering. I tried defining x as an integer first, but that still didn't work. Thanks for the quick response.
Actually now I'm getting the error
undefined function 'simplify' for input arguments of type 'double'.
I tried your code and it gives me a specific answer. I want to simplify an expression. Not get a specific answer.
simplify() requires the Symbolic Toolbox, and it works on symbolic expressions.
syms x
simplify( sin(x)^2 + cos(x)^2 )

请先登录,再进行评论。

更多回答(1 个)

The function u[1]/(u[2]^0.5) shows the error "result of the function is undefined" in matlab simulink user defined function. What could be the reason?

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by