Next: Stuff to write up Up: Math 0250 Computer Assignment Previous: What you'll need

# Getting started

Once you have Matlab or Octave up and running, you should do a few simple calculations to get a feel for how it works. Try something like
```  2+3
```
followed by the enter key. Then try each of the following:
```  2*3
a = 2
b = 3;
a*b
a b
sin(a)
i^2
i^i
log(-1)
```
A couple of things should be noted here. First, the input ``b=3;'' produced no output. That doesn't mean that nothing happened, as you can see from the output from the subsequent input line. The effect of the semicolon is to suppress the output. That's important to remember when you enter commands that produce a lot of numbers that you don't really want to see. Secondly, the computer complained bitterly about the input ``a b''. That's because a blank space is not interpreted as an implicit multiplication sign.

One of the things you'll need to do often is to produce a list of numbers. Try entering

```  1:5
```
You should get a list of numbers from 1 to 5, spaced 1 unit apart. You can change the spacing like this:
```  1:0.5:5
```

Now let's see if we can produce a picture. Make a list of equally spaced x values with

```  X = -1:0.1:1;
```
Notice the use of the semicolon to suppress the output of the list of 21 numbers, which you probably didn't want to see. (If you do want to see them, just enter X.) Now make a new list consisting of the squares of the numbers in the X list:
```  Y = X.^2;
```
Once again, a semicolon was used to suppress the output. Note also the use of the dot before the power operator. The dot tells the computer to perform the indicated operation on each member of the list X. If you want to confirm that you got the right thing, you can enter
```  [X;Y]
```
to output the two lists arranged in an array with X in the first row and Y in the second. Finally, let's plot Y as a function of X with
```  plot(X,Y)
```

Next: Stuff to write up Up: Math 0250 Computer Assignment Previous: What you'll need
Frank Beatrous
1/8/1998