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

3 ビュー (過去 30 日間)
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.

採用された回答

Meghana Dinesh
Meghana Dinesh 2016 年 2 月 6 日
編集済み: Meghana Dinesh 2016 年 2 月 6 日
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 件のコメント
MichaelTee
MichaelTee 2016 年 2 月 6 日
I tried your code and it gives me a specific answer. I want to simplify an expression. Not get a specific answer.
Walter Roberson
Walter Roberson 2016 年 2 月 6 日
simplify() requires the Symbolic Toolbox, and it works on symbolic expressions.
syms x
simplify( sin(x)^2 + cos(x)^2 )

サインインしてコメントする。

その他の回答 (1 件)

Bala Abhirami
Bala Abhirami 2021 年 5 月 25 日
編集済み: Bala Abhirami 2021 年 5 月 25 日
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?
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 25 日
Simulink uses MATLAB indexing syntax, so you need () instead of []
u(1)/(u(2)^0.5)
You might be able to use
u(1)/sqrt(u(2))

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by