solving algebraic equations and characteristic vectors

1 回表示 (過去 30 日間)
metin yilmaz
metin yilmaz 2020 年 11 月 7 日
コメント済み: Stephan 2020 年 11 月 7 日
I am very new in matlab. I am struggling with warnings when I am trying to solve algebraic equaions. Would you please help me understand the situation?
When I do this operation: >> solve('x^2-5*x+6=0')
I take this warning, and I don't understand anything from it. What is character vector here?
  1. Warning: Support of character vectors will be removed in a future release. Character vectors can be used only for variable names and numbers. Instead, to create
What is characteristic vector here?
2.symbolic expressions first create symbolic variables using 'syms'. To evaluate character vectors and strings representing symbolic expressions, use 'str2sym'.
What does 2 says?
> In sym>convertExpression (line 1581)
In sym>convertChar (line 1486)
In sym>tomupad (line 1236)
In sym (line 215)
In solve>getEqns (line 406)
In solve (line 226)
Warning: Do not specify equations and variables as character vectors. Instead, create symbolic variables with syms.
> In solve>getEqns (line 446)
In solve (line 226)

採用された回答

Stephan
Stephan 2020 年 11 月 7 日
編集済み: Stephan 2020 年 11 月 7 日
Try:
syms x
sol = solve(x^2-5*x+6==0)
Character is a data type that is defined by '...' like you did. For symbolic expressions in future releases this support will be removed.
If you want to solve symbolic expressions you need to tell matlab what the symbolic variables are. For that use syms command.
  2 件のコメント
metin yilmaz
metin yilmaz 2020 年 11 月 7 日
Thank you but how many times shoud I enter syms command? In every new equation?
Stephan
Stephan 2020 年 11 月 7 日
Only once

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

その他の回答 (2 件)

Star Strider
Star Strider 2020 年 11 月 7 日
The term MATLAB uses here is ‘character’, not ‘characteristic’.
A character vector is a vector make up of ASCII characters defined by single quotes at the beginning and end of the vector (see the char function).
This will do what you want, and not throw the warning:
syms x
xs = solve(x^2-5*x+6==0)
.
  1 件のコメント
Star Strider
Star Strider 2020 年 11 月 7 日
Enter the syms command only once, when you first need to declare the variables.
You will need to do that each time you begin a new session with the Sybolic Math Toolbox.

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


metin yilmaz
metin yilmaz 2020 年 11 月 7 日
How many times should I enter syms command? In every new equation?

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Preferences についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by