how can i erase 'ans =' ? in my source code there is no 'ans ='. please help thanks

2 Comments

Guillaume
Guillaume on 18 Dec 2017
However, since that output is not assigned to anything, one must ask why was the calculation done in the first place. Probably a bigger bug than the failure to suppress the output.

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 18 Dec 2017
Edited: Guillaume on 18 Dec 2017
Matlab display ans = ... when you call a function that returns an output and don't assign that output to a variable. e.g. if you do
>> sin(pi/2)
You'll get
ans =
1
In addition, matlab only display the outputs of a function if you don't suppress that display with a colon. e.g. if you do
>> sin(pi/2);
You get nothing.
Therefore, there are two problems with your code:
  • you didn't put a semicolon at the end of a line,
  • you calculate something but never assign it to anything.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

No tags entered yet.

Asked:

on 18 Dec 2017

Commented:

on 18 Dec 2017

Community Treasure Hunt

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

Start Hunting!