Lec 5
Lec 5
1 2 −1 3 0 5
𝑎=[ ] , 𝑏=[ ] 𝑡ℎ𝑒𝑛 𝑎 + 𝑏 = [ ]
3 4 −2 1 1 5
You can change the format by selecting the “Preferences” icon on the
Toolstrip. This option will pop up the Preferences Window, and the
format can be selected from the “Variables” item in the preferences list
see Figure
**The disp Function
Another way to display data is with the disp function. The disp function
accepts an array argument and displays the value of the array in the
Command Window. If the array is of type char, then the character string
contained in the array is printed out.
This function is often combined with the functions num2str (convert a
number to a string) and int2str (convert an integer to a string) to create
messages to be displayed in the Command Window. For example, the
following MATLAB statements will display
“The value of pi = 3.1416” in the Command Window. The first
statement creates a string array containing the message, and the second
statement displays the message.
str = ['The value of pi = ' num2str(pi)];
disp (str);