Octave equivalent to Python's print

In Python you can use print:

print_example.py
print("foobar")

whereas in Octave you can use disp:

example.txt
disp("foobar")

You can print numbers using print in Python:

example.py
x = 1
print(x)

and also using disp in Octave:

example.txt
x = 1
disp(x)

Note that you can use multiple argument to print in Python:

example.py
x = 1
print("The value of x is", x)

whereas in Octave you need to use disp together with cstrcat:

example.txt
disp(cstrcat("The value of x is ", num2str(x)))

 


Check out similar posts by category: Octave