フィルターのクリア

Having problems with display function

2 ビュー (過去 30 日間)
Viet Anh Nguyen
Viet Anh Nguyen 2021 年 1 月 8 日
回答済み: Walter Roberson 2021 年 1 月 8 日
Why can't I put the variable from a solve function into a display function? For example:
syms x
y=x+3
sol=solve(y==0)
disp("sol is" + sol)
There is an error with the display function and I don't know how to fix it. Also, what type of data is the outcome of the solve function?

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 8 日
disp("sol is " + string(sol))
The output of solve is sym if a single variable is being solved for, or in some cases where multiple outputs are given, and otherwise is struct.
You have a conflict over whether the + operation should be the concatenation operation of the string object "sol is" or if it should be symbolic addition associated with the sym result of solve. Addition happens to win, and that is a problem for you.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by