Matlab prints comments and other script content in command window

Below is the script in which I am summing the elements of the vector. My problem is that whenever I run the script, Matlab prints everything in the command window. That is, it prints out comments and everything else.

I only wanted to print the sum as the result, so I didn't put ;

after y = sum(x)

.

Can anyone help me prevent Matlab from printing script comments and contents other than the ones I only want to print? Below is the script list

%simple script
%this script sums the number of elements in a vector.
x = 1:2:10;
y  = sum(x)

      

Here is the output in the command window output

+3


source to share


1 answer


Apparently echo on

installed in your MATLAB. You need to disable it:



>> echo off

      

+6


source







All Articles