Uploaded by Shel The Don

Lab 1 Report

advertisement
Electrical and Computer Engineering
ENGR 2341 – Introduction to Signal Processing
LAB 1 Report
Due: 11:59 PM Mon 01/18/2021
By: Sheldon Robinson #901001241
Date: 01-18-2021
1. Introduction to MATLAB (15 pts)
Part 1: Find answers for the following questions. (6 pts)
Note: This Part asks you descriptive answers. No code needs to be attached.
(a) Look for “rand” function by typing “doc rand” in the command line. Following what
distribution does the function generate random numbers? (2 pts)
Hint: Normal, Uniform, Poisson, etc?
The numbers are generated by random uniformly.
(b) Looking up doc rand in MATLAB will let you know that the range of each random number
that is generated by “rand” function is [A, B]. Find A and B. (2 pts)
A and B are considered intervals. So if interval A is 3 and interval B is 4, the randomized matrix
that will be generated is a 3-by-4 matrix.
(c) Write an expression for generation of a 10-by-1 vector that is filled with uniform random
variables on the interval [M, N]. (2 pts)
Note: Use rand() function.
r = M + (N + N)*rand(10, 1)
Part 2: Construction of matrices (9 pts)
(a) Generate a 10-by-10 matrix that is filled with uniform random variables on the interval [7,
15].
Hint: Use what you found in Part 1-(c). (3 pts)
Attach your code here.
r = 7 + (15 - 7)*rand(10,10)
r=
13.0395
7.9669
7.1566
10.1743
13.6680
10.2556
10.9614
13.5232
8.8227
12.0077
8.9423
13.9017
9.6469
13.4681
13.1508
12.9896
8.5177
14.0321
10.9848
12.2876
10.5392
10.8744
10.3945
13.0406
8.3380
13.6047
10.9600
14.9113
14.2068
12.8380
12.5024
13.7588
9.1622
10.0192
13.8958
13.3197
8.1809
7.0042
11.5973
14.1260
9.8738
8.5764
8.7282 14.9190
9.5482
7.4398 13.9235 13.7614 14.8584
8.6752
12.8907
11.4183
13.5738
13.3233
11.1154
11.2725
13.8057
11.9005
12.9091
13.1522
10.1577
12.0391
10.4394
14.5944
14.0742
7.7196
11.4845
14.9196
11.6879
11.6516
12.4673 14.1022
12.6324
11.9177
9.6205 11.7042
10.1295
12.3701
10.5384 13.1529 10.5092
7.8936 14.4369 11.2214
8.2380
8.0903
12.5733
8.9739 14.4265
10.8362
8.5989 12.4292 11.6623 13.4108
12.3313
7.6679
7.1359
7.2559
11.6407
9.8993
(b) Generate a 10-by-10 matrix that is filled with “integers” following uniform distribution on
the interval [1, 10]. (3 pts)
Hint: Use randi() function.
Attach your code here.
>> r = randi([1 10],10,10)
r=
1
5
2
2
2
4
10
2
10
2
3
4
10
7
4
6
9
3
5
3
2
10
10
8
7
6
6
2
2
4
2
4
6
7
8
9
7
3
3
5
3
2
1
5
1
8
6
5
5
6
5
8
3
6
10
7
3
4
6
1
1
4
4
3
8
4
4
10
3
3
10
3
9
8
5
9
5
5
7
9
10
5
1
2
5
6
3
2
8
1
5
1
1
7
5
4
9
10
3
10
(c) Generate a 10-by-10 matrix that is filled with random variables following NORMAL
distribution. (3 pts)
Hint: Use randn() function.
Attach your code here.
r = randn(10)
r=
-1.4264
0.0303 -0.5927
-1.0145
0.8531 -0.4698 -0.5686
-0.2133
0.4043
0.8864
-0.3253 -0.7006 -1.3852
0.9704 -1.5505
0.1716
2.7891
0.4011
0.4120
0.4772 -0.5435
0.7276
0.9297
0.4055 -0.0713 -0.9119
0.8100 -0.0621 -0.7731 -1.6058 -0.3638 -0.9383
0.1732
1.9444 -1.6305 -1.9568 -0.5055
1.1990
0.8366
0.8017 -1.1283
0.6615 -0.5993
0.6527
0.1614 -0.7343
2.1385 -0.5896 -0.2682
0.5406
-0.5718
1.4600
0.4207 -1.1933
-0.2500
2.0500
0.4007
-1.5693
0.1205
0.0951 -0.3536 -0.9363 -0.7779 -0.2031 -0.2073
0.6470 -0.7489
-0.4774 -0.9899
0.4967
-1.3380
1.0822 -0.7929
1.1978
1.0533 -1.4245
0.0464 -1.2691
0.4980
0.5411
0.8535 -0.4099
0.9758
0.7174 -1.5409 -1.8530 -0.7113 -0.1569
0.3160 -0.5000
1.4065
0.0614
0.2778
0.2704 -1.8461
0.6395
0.3830 -0.6528 -0.3983 -0.0810
2. Creation and operation of vectors (15 pts)
Part 1: Create column vector that contains 1 through 10 in the ascending order. (2
pts)
Attach your code here.
>> r = 1 + (10-1).*rand(10,1)
r=
2.2087
1.8873
2.2782
2.5143
2.7662
3.8573
3.8479
2.9581
3.2594
9.0363
>> B = sort(r)
B=
1.8873
2.2087
2.2782
2.5143
2.7662
2.9581
3.2594
3.8479
3.8573
9.0363
Part 2: Find the transpose of the column vector found in Part 1. (2 pts)
Attach your code here.
>> A = transpose(B)
A=
Columns 1 through 8
1.8873
2.2087
2.2782
Columns 9 through 10
2.5143
2.7662
2.9581
3.2594
3.8479
3.8573
9.0363
Part 3: Create two 2-by-2 matrices as below
and find A+B, A-B, and A*B. (6 pts)
Hint: A*B is a matrix multiplication, not an element-wise multiplication.
Attach your code here.
>> A = [1 0; 0 1]
A=
1
0
0
1
B=
0
2
2
0
Part 4: Flip the matrix given below left-to-right then up-to-down. (5 pts)
Note: Keep the order: left-to-right then up-to-down
Attach your code here.
>> C = [1 2 3; 6 5 4; 9 8 7]
C=
1
2
3
6
5
4
9
8
7
Download