Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1.

Starting
a)
a. 1.0323
b. -0.6459
c. 0.6781
b)
a. 20.0855
3.0000
1.3029
5.0000
b. 2.6254e+017
c. 2.5789
c)
x = 1 2 3 4 5
Output vectors:
a. 2.0000 1.3333 1.1429 1.0667 1.0323
b. -1.0000 -0.7868 -0.7058 -0.6667 -0.6459
d)
a.
b.

e) Array should output

1 4 9 16 25 36 49 64 81 100

f) Array should output


1 8 9 64 25 216 49 512 81 1000
2.To the finish and back

a) X should be a vector with values 1 to 100

b) Sum = 5050

c) P = 101

d) n = 50

e) P*N = 5050

f) Sum = 45150

3. Going diagonal

Solutions are directly put on screen. If you can’t do this exercise


please read the oncourse module on this part carefully. (The “Arrays:
Vectors and Matrices” chapter)

4. Round and Round...

a)

theta =

0 1 2 3 4 5 6

b)Vector starts at 0 and has steps of 1. So it will not exactly reach


the value of 2ʌ.

c) The vectors X and Y should have these values:

X =

5.0000 2.7015 -2.0807 -4.9500 -3.2682 1.4183


4.8009

Y =

0 4.2074 4.5465 0.7056 -3.7840 -4.7946 -


1.3971
d)Plot result:

A rounder circle can be achieved by using a smaller step size in


theta. This will also make sure the ends seem better connected

e) Combine the answers from a) and c) and put them in the function.
The vectors X and Y should not change using this function.

f) The commands you should use:

[X,Y]=circ(5);

plot(X,Y);

g) use the circ command in your script.

h) search the documentation (http://www.mathworks.com/help for


“retaining mulitple plots in a window”)
i) Using a step size of 0.01, an example of an output could be. (R=5
and R=10)

5. Got it!

a) A should be a 5x3 matrix


B should be a 5x1 matrix

b) Use the mathworks documentation

c) Output of the command is

ans =

1 0 0 1

0 1 0 5

0 0 1 25

0 0 0 0

0 0 0 0

This means that X=1,Y=5,Z=25


ͳ
d) After creating the vector ൥ ͷ ൩. The multiplication of A with
ʹͷ
this vector should return B

e) see the help command for mldivide.

f)

ans =

1.0000

5.0000

25.0000

g) A lot of commands can be used. linsolve for example is


mentioned in the help of mldivide!

You might also like