Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Table of Contents
Vectors .............................................................................................................................. 1
Functions ........................................................................................................................... 1
Plotting .............................................................................................................................. 2
Polynomials as Vectors ........................................................................................................ 3
Polynomial Using the s Variable ............................................................................................ 3
Matrices ............................................................................................................................. 4
Vectors
a = [1 2 3 4 5 6 7]
t = 0:2:20
b = a+2
c = a + b
a =
1 2 3 4 5 6 7
t =
0 2 4 6 8 10 12 14 16 18 20
b =
3 4 5 6 7 8 9
c =
4 6 8 10 12 14 16
Functions
sin(pi/4)
help myFunctions
y = myFunction(3)
1
Experiment No. 1
ans =
0.7071
y =
27
Plotting
t = 0:0.25:7;
y = sin(t);
plot(t,y);
title('Sine Wave as a Function of Time')
xlabel('Time(secs)')
ylabel('Amplitude')
2
Experiment No. 1
Polynomials as Vectors
The following line creates a polynomial s^3+3*s^2+4*s+5
poly1 = [1 3 4 5];
poly1_val =
33
poly1_roots =
-2.2134 + 0.0000i
-0.3933 + 1.4506i
-0.3933 - 1.4506i
z =
1 6 16 16
xx =
1 2
R =
0 0 0 0
3
Experiment No. 1
s = tf('s')
s_poly1 = s^3+3*s^2+4*s+5
s =
s_poly1 =
s^3 + 3 s^2 + 4 s + 5
poly1_zero =
-2.2134 + 0.0000i
-0.3933 + 1.4506i
-0.3933 - 1.4506i
Matrices
B = [1 2 3 4; 5 6 7 8; 9 10 11 12]
mat2 = [5 6
7 8]
4
Experiment No. 1
mat1_elements_to_5 = mat1.^5
B =
1 2 3 4
5 6 7 8
9 10 11 12
C =
1 5 9
2 6 10
3 7 11
4 8 12
D =
30 70 110
70 174 278
110 278 446
mat1 =
1 2
3 4
mat2 =
5 6
7 8
mat1_x_2 =
19 22
5
Experiment No. 1
43 50
mat1_to_5 =
1069 1558
2337 3406
mat1_elements_to_5 =
1 32
243 1024
X =
-2.0000 1.0000
1.5000 -0.5000
E =
-0.3723
5.3723
p =
r =
5.3723
-0.3723