Next: Managing M-files Up: No Title Previous: M-files

Text strings, error messages, input

Text strings are entered into MATLAB surrounded by single quotes. For example,

 
s = 'This is a test'
assigns the given text string to the variable s.

Text strings can be displayed with the function disp. For example:

 
disp('this message is hereby displayed')
Error messages are best displayed with the function error
 
error('Sorry, the matrix must be symmetric')
since when placed in an M-File, it causes execution to exit the M-file.

In an M-file the user can be prompted to interactively enter input data with the function input. When, for example, the statement


 iter = input('Enter the number of iterations:  ')
is encountered, the prompt message is displayed and execution pauses while the user keys in the input data. Upon pressing the return key, the data is assigned to the variable iter and execution resumes.


ladi@
Wed Mar 13 19:15:55 MET 1996