Output Text to Octave Console

As per official documentation,

Note that the output from disp always ends with a newline.

so to avoid the newline, you should use an alternative to output data for each string, or first concatenate a single string and then disp it.

ThiS listed options.


You can use:

A = 5
printf("There are %d horses\n", A)

output:

There are 5 horses

or even

disp(["There are ", num2str(A), " horses"])

or even

disp(strcat("There are ", num2str(A), " horses"))

but you will have to add something because octave/matlab don't let the white space at the end of a string, so the output is:

ans = There are5 horses