An interactive introduction to MATLAB

(Jeff_L) #1

36 scripts and functions


The disp function
Thedispfunction can be used display strings of text to the Command Window
e. g.disp('I am a string of text'). You can also display numbers by
converting them to strings e. g.disp(num2str(10)). Thenum2strfunction
simply converts the number 10 to a string that can be displayed by the
dispfunction. You can also combine the display of text and numbers e. g.
disp(['Factorial ' num2str(x) 'is ' num2str(y)]). Notice the use of
spaces to denote the separate elements of the string, and square brackets around
the string to concatenate it together.
Free download pdf