different result of unchanged script after restart of Matlab (symbolic)

1 view (last 30 days)
I have a script with only the following two lines:
syms x
solve(x^2)
If this script is run as first command after starting Matlab the result is:
ans = 0
0
After running some other commands the result of running the same and unchanged script is:
ans =
[1x1 empty sym]
This problem occured during a beginner's course at university. It occured on different computers all running openSuse. Clearing the workspace did not solve the issue.
My question is: Is this a bug or what exactly (other than the workspace) should be cleared or changed to get the expected (first) result?

Answers (1)

Sean de Wolski
Sean de Wolski on 2 Apr 2015
Whenever you run any command without assigning its output to a variable, the output is assigned to ans
>>5
>>magic(3)
If you want to store it for later, assign it to a variable rather than using the default:
>> x = 5
>> y = magic(3)
  1 Comment
Qwert
Qwert on 2 Apr 2015
Thank you for your answer, but it does not match my question ;). I run the script and get an answer. Then I do some other symbolic things. After that I clear the workspace and run the script again. Now the answer is different from the first.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!