Computer Lab 1

Computer Lab 1 : Logging on/off and matlab primer

To log on:

Username: ims0xxx

Password (initially is): 00-xxxxxxxx

where xxxxxxxx is your 8 digit student ID number.

To log off:

Place mouse somewhere in background, click left mouse button and select "Exit Window Manager"

Change Your Password:

When you log in change your password to some combination of 8 letters, numbers and/or punctuation marks. Type:

kpasswd

in your C-chell window. The command will prompt you to enter your old password, and new password twice.

Web access Type

netscape &

Enter:

http://www.math.montana.edu/~pernarow

and then "Return". Click "Courses" then "M441".

MATLAB Type "matlab" and wait. The screeen should look like:

The ">>" is the matlab prompt where commands can be entered. To exit matlab:

>>quit

Arithmetic Calculations Try the following commands:

x=10

y=20

x*y

x/y

x+y

x^y

sin(x)

atan(x)

log(x)

z=2*x-y*x

z

Vectors Row vectors can be entered in two ways. Try the following:

x=[5 6 7 8]

x=[5,6,7,8]

If you want to make it a column vector use the ' symbol to take the transpose

y=x'

or enter it directly as

y=[5;6;7;8]

The the i-th component of a vector

y(2)

y(2)*y(4)

z=y(1)+y(2)+y(3)

Entering large vectors with equal increments:

x=0:1:10

creates a vector with 11 components ranging from 0 to 10 in increments of 1. Try

y=-1.1:0.1:-0.3

Doing this may create huge vectors. If you don't want matlab to show the value you assigned put a semicolon at the end

y=0:0.01:1;

Vector calculations The symbols + - * / ^ are reserved for scalar calulations. Putting a dot in front changes them to component by component calculations on vectors (and matrices). For instance

You can also use elementary math functions as in

x=0:0.2:2

y=sin(2*x)

Basic plots

To make a plot of sin(x)^2 on [0,10] try

x=0:0.1:10;

y=sin(x).^2;

plot(x,y);

plot(x,sin(x).^2);

Sums and series

If you want to sum the components of a vector use the sum command

x=1:1:10;

sum(x)

would return the sum of 1+2+3+4+...+10. So suppose you wanted to sum the series

1+1/2^2+1/3^2+1/4^2+...1/7^2

you could type

n=7;

x=1:n;

y=1./x.^2;

sum(y)

Change n and try again