Winter 2000

- Start
- Programs
- Scientific
- Matlab 5.2

- help
- helpwin
- lookfor

TO DO:

- At the command prompt, type
>> help help

The second

**help**can be substituted by any other help topic. - Explore the help window. Open it using the menu bar on the MATLAB
command window, or by typing at the command prompt
>> helpwin

- Use any of the above to find the name of the MATLAB function to compute the eigenvectors and eigenvalues of a matrix.
- Find out how to use this function.

- who/whos
- clear
- save
- load

TO DO:

- Type the following at the command prompt and observe what happens:
>> a = 5

>> b = 10.1123

>> c = [1;2]

>> who

>> clear a

>> whos - Use the
**save**command to save the values of the variables**b**and**c**onto a file called**bc.mat**on your user directory and clear the workspace. You can use the command**cd**to change your current directory.>> save bc.mat b c

>> clear

>> who - Reload the variables from the file:
>> load bc

- Verify that both the variables
**b**and**c**are loaded on your workspace.

- The first part of the
demo file on the course web page has basic examples on how to work
with matrices. Try typing the uncommented lines at the command prompt to
see how they work.
(In the file, comments are preceded by %.)
- The following are useful as well, find out what they do:
- size
- eye
- ones

- The second part of the same demo file illustrates how to make simple plots. Try generating the plots and note their differences. (Skip the part on user-defined functions for now.)

Commands to know:

- pwd
- path
- addpath
- rmpath

TO DO:

- Create a file on your user directory called
**plotxy.m**. Using the MATLAB editor or any other text editor, type in the following lines and save the file:x = [-10:10];

y = x.*x;

plot(x,y);

xlabel('X');

ylabel('Y');

axis([-10 10 -10 100]);

grid on;

title('The Quadratic Function'); - To run the script, the file has to be in the current directory
or on MATLAB's search path. Check by typing at the command prompt
>> pwd

>> path - Add your user directory to the search path by typing
>> addpath N:\substitute_your_own_path

- Now you can run the script by typing
>> plotxy

- You can remove the directory from the path by typing
>> rmpath N:\substitute_your_own_path

TO DO:

- Copy the example function on the course web page into your local user
directory.
- Now you can continue with the last section on the demo file dealing with user-defined functions.

- Check out the
**diary**command. You can save the command history and results of the workspace onto a file. - Recall commands by using the UP-ARROW and DOWN-ARROW keys at the command prompt.
- Recall specific commands by typing the first letter(s) and the ARROW keys. Ex.,
>> plot

Then hit the UP-ARROW key.