To print something in Matlab, you can use the disp
function. For example, to print the string "Hello, world!", you would type:
main.m23 chars2 lines
This will display the text on the command window. If you want to print a variable, you can just include it in the disp
call:
main.m17 chars3 lines
This will print the value of x
(in this case, 42
) to the console.
You can also use fprintf
function to display formatted text:
main.m85 chars4 lines
This will print "The value of x is 42 and the value of y is hello" to the console.
gistlibby LogSnag