How to get == to help solving equations

Hello.
I cant get my matlab to stop putting out logical when i use the == command before trying to solve.
syms y
x = 5*y == 20
solve(x,y)
I can see that it makes sense that matlab says that 5*y is not equal to 20
but my study buddies can use the solve command after on x for the variable y to solve equations in matlab.

回答 (2 件)

madhan ravi
madhan ravi 2020 年 10 月 15 日
編集済み: madhan ravi 2020 年 10 月 15 日

0 投票

You should have the Symbolic Math Toolbox and the license for it to perform the above operation. In order to replicate your message , experimented with the below code:
>> y = 1
y =
1
>> syms y
x = 5*y == 20
solve(x,y)
x =
5*y == 20
ans =
4
>>
So probably it has to do with you not having the toolbox/license.

3 件のコメント

Henrik Kristiansen
Henrik Kristiansen 2020 年 10 月 16 日
編集済み: Henrik Kristiansen 2020 年 10 月 16 日
i just installed the toolbox and it still doesnt output 4 for y
still gives me "logical = 0"
and when i install the toolbox, then the simplify command wont work on some of my other equations in my scripts :s
madhan ravi
madhan ravi 2020 年 10 月 16 日
which syms -all % what does it show?
Henrik Kristiansen
Henrik Kristiansen 2020 年 10 月 16 日
ive fixed it by uninstalling all toolbox's and reinstalling them again.
Thanks for the help tho :)

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

Steven Lord
Steven Lord 2020 年 10 月 16 日

0 投票

My guess would be that you had redefined y between the syms call and when you tried to use it as a symbolic variable.
syms y
f = 5*y == 20 % symbolic equation
syms z
z = 2; % z is no longer symbolic
g = 5*z == 20 % logical false as 10 is not equal to 20

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2020 年 10 月 15 日

回答済み:

2020 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by