We've discussed the control of Output that comes from using the semicolon (;) at the end of MATLAB commands. Another means of output control of how your MATLAB scripts comes from the echo on and echo off commands. The default situation is to have MATLAB echo each command when you run a MATLAB script. This can lead to a large amount of information being placed on your screen. One way to control the scrolling of information on the screen is through the more command.
Have you had the chance to use the MATLAB diary command? I find this an effective mechanism to keep track of my output as well as some of my explorations.
Another way to control this is to insert echo off in you MATLAB scripts. Then only explicit output command, such as disp and fprint will cause output to be written to your screen.
In Module 2, we began to look at Input/Output Module2/Apply. At this time we focussed on the disp command which will display a single data item, either a number or a string. We also examined the fprintf command which allowed a great deal of flexibility and control over the output, requiring the programmer to specify how easy data item is printed following the standard C format programming language conventions.
MATLAB is a vector oriented language. In the case of I/O, the data specifier will be applied to each element of the vector. Try this out using
The reshape command takes the vector of integers 32,33,34...,127 and reshapes them into a 16 by 6 matrix. This will make a nice display for the char command.
to see the Symbol and Wingdings. These characters look best on a Mac or PC.
Strings are an interesting complement to working with numbers.
The key structure is given below - the reserved words of MATLAB, i.e. the words that must be used just so are in bold. Suppose you want to write a function with the name myfun with one output value output1 and two input values in1 and in2.
function output1 = myfun (in1,in2) Suppose you want to write a function with the name yourfun with two output values output1 and output2 and two input values in1 and in2
function [output1,output2] = myfun (in1,in2)
Note, when there are more than one output values, we must use the brackers [].
An important new concept presented in the document above concerns the MATLAB variables to be shared between functions, but not placed in the input parameter list. The is accomplished by placing the declaration
allowing the user-defined function