How can I use matlab to find the solution of an equation when equal to zero using variables without substituting with numbers?

I want to find how can I use matlab to find the solution of an equation when equal to zero using variables without substituting with numbers?
for example if the equation is : (x^2) - (y^2) = 0
the answer will be (x=y)

 Accepted Answer

That is what the 'solve' function of the Symbolic Toolbox endeavors to do. It is not always successful, but it capable of some remarkable results.

3 Comments

Thank you very much for your answer, I tried to use 'solve' but i didn't give me the expected answer, as you see below:
syms u v [solv, solu] = solve([u^2 - v^2 == 0], [v, u])
solv =
0
solu =
0
while I expected to give me answer (x=y)
Actually it worked with one variable only:
syms a b c x y sol = solve(x^2 - y^2== 0)
sol =
y
-y
but how can i use it with 2 variables ?
You just have to ask it in a way it understands:
syms u v
v = solve([u^2 - v^2 == 0], v)
produces:
v =
u
-u

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!