-4

MATLAB simulates solve(a==a) and returns 0. The solution should have been infinitely many (the solution should have looked like a=a) but it simulates the solution equal to zero which is incorrect. How can I fix this?

gnovice
  • 125,304
  • 15
  • 256
  • 359

1 Answers1

3

Zero is a correct solution for a: it's the "simplest" one. By default, solve will just return one solution for a case with infinitely many, and that one solution happened to be zero here. However, you can get a set of parameterized solutions by setting the 'ReturnConditions' flag to true. For the above example, you would get:

>> syms a
>> [sol, params, conds] = solve(a == a, 'ReturnConditions', true)

sol =

z

params =

z

conds =

TRUE

The solution is just a parameter z with no restrictions (i.e. it can be any value).

gnovice
  • 125,304
  • 15
  • 256
  • 359