remove ans in matlab

If you want to remove the variable "ans" generated by Matlab in its command window, you can do so by suppressing output using a semicolon ";" at the end of your command. For example:

main.m
x = 5 + 6;
11 chars
2 lines

This will output:

main.m
x =

    11
12 chars
4 lines

But if you add a semicolon:

main.m
x = 5 + 6;
11 chars
2 lines

This will not output anything to the command window. Therefore, no "ans" variable will be created.

Another way to remove the "ans" variable is to clear it manually by entering the following command at the prompt:

main.m
clear ans
10 chars
2 lines

This will remove any existing "ans" variable in the workspace.

related categories

gistlibby LogSnag