How to erase this?
Show older comments
how can i erase 'ans =' ? in my source code there is no 'ans ='. please help thanks
2 Comments
Stephen23
on 18 Dec 2017
You just need a semi-colon to suppress displaying any output:
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.
Answers (1)
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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!