How can I solve an equation that is logical?

2 ビュー (過去 30 日間)
Lars Bosma
Lars Bosma 2019 年 2 月 22 日
回答済み: Prateek Rai 2020 年 6 月 19 日
For my question I will take the following standard script:
syms x
eqn = sin(x) == 1
solx = solve(eqn,x)
Matlab sees eqn now as a 1x1 logical with a value of 0.
1.jpg
This should result in x = pi/2 however Matlab gives the following answer:
solx = x
Does anyone know how I can solve this?
  1 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 22 日
use clear all and try again maybe?

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

回答 (1 件)

Prateek Rai
Prateek Rai 2020 年 6 月 19 日
As per my understanding, you are trying to solve the equation sin(x)==1 and and having issue with variable "eqn"
You can try these two things:
(a) clear all
(b) declare eqn as sym:
syms eqn
You can refer to the following documentation for more details on “solve” function.

カテゴリ

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

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by