Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

suppressing printing every assignment

Tags:

octave

I have written a simple script in Octave. When I run it from the command line, Octave prints a line every time a variable gets assigned a new value. How do I suppress that?

MWE:

function result = stuff()     result = 0     for i=0:10,         j += i     end end 

when I run it:

octave:17> stuff() result = 0 result = 0 result =  1 result =  3 result =  6 result =  10 result =  15 result =  21 result =  28 result =  36 result =  45 result =  55 ans =  55 octave:18>  

I want to get rid of the result = ... lines. I am new to Octave, so please forgive me asking such a basic question.

like image 452
icehawk Avatar asked Aug 19 '15 14:08

icehawk


People also ask

How do you suppress the printing of a result after an assignment statement?

by adding a semicolon at the end of your statement it will suppress the intermediate result. will do the trick. Save this answer.

Can you suppress output in R?

In this article, we are going to discuss how to suppress the output of a command in R programming language. Suppressing means making the output invisible. We can make the output should not appear. By using invisible() function we can suppress the output.


2 Answers

by adding a semicolon at the end of your statement it will suppress the intermediate result.

In your case:

function result = stuff()     result = 0;     for i=0:10,         j += i;     end end 

will do the trick.

like image 70
DJanssens Avatar answered Sep 23 '22 04:09

DJanssens


Like in matlab just add a ; (semicolon) to the end of a line you don't want output to the terminal.

like image 24
Rufus Shinra Avatar answered Sep 23 '22 04:09

Rufus Shinra