Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Signal and system matlab exercise

Lab assignment # 1
E.1 (a)
>> T=[32:2:75]
T=
Columns 1 through 21
32 34 36 38 40 42
68 70 72
Column 22
74

44

46

48

50

52

(b)
>> U=[75:2:131]
U=
Columns 1 through 20
75 77 79 81 83 85 87 89 91 93 95
109 111 113
Columns 21 through 29
115 117 119 121 123 125 127 129 131
(c)
>> A=1:100
A=
Columns 1 through 20
1 2 3 4 5 6
20
Columns 21 through 40
21 22 23 24 25
39 40
Columns 41 through 60
41 42 43 44 45
59 60
Columns 61 through 80
61 62 63 64 65
79 80
Columns 81 through 100
81 82 83 84 85
99 100
E.2 (a)

54

56

58

60

62

64

66

97

99 101 103 105 107

10

11

12

13

14

15

16

17

18

19

26

27

28

29

30

31

32

33

34

35

36

37

38

46

47

48

49

50

51

52

53

54

55

56

57

58

66

67

68

69

70

71

72

73

74

75

76

77

78

86

87

88

89

90

91

92

93

94

95

96

97

98

>> X=[2 5 1 6]
X=
2 5 1 6
>> X+16
ans =
18 21 17 22

Federal Urdu university of arts science and technology

Signal and system matlab exercise


(b)
>> X(2)=5+3
X=
2 8 1 6
(c)
>> sqrt(X)
ans =
1.4142 2.8284
E.3

1.0000

2.4495

>> X=[3 2 6 8]'


X=
3
2
6
8
>> Y=[4 1 3 5]'
Y=
4
1
3
5
>> a=X+Y
a=
7
3
9
13
(c)
>> z=X*Y
z=
12
>> z=X.*Y
z=
12
2
18
40
2
18
40
>> z=Y.*X

Federal Urdu university of arts science and technology

Signal and system matlab exercise


z=
12
2
18
40
E.4 (a)
>> 2/(2*3)
ans =
0.3333
(b)
>> C=6-2/(5+7^2-1)
C=
5.9623
(c)
>> D=10/(2\5-3+2*4)
D=
1.3333
>> E=3^2/(4)
E=
2.2500
E.5 (a)
>> S=[2:2:50]
S=
Columns 1 through 21
2 4 6 8 10 12
38 40 42
Columns 22 through 25
44 46 48 50
(b)
>> T=[10:-2:-4]
T=
10 8 6 4

14

-2

16

18

20

22

-4

E.(10)
>> O=[12 15 16;23 26 27;31 40 41]
O=
12 15 16
23 26 27
31 40 41
>> P=[22 35 56;63 66 78;24 30 46]

Federal Urdu university of arts science and technology

24

26

28

30

32

34

36

Signal and system matlab exercise

P=
22 35
63 66
24 30
>> O+P
ans =
34 50
86 92
55 70

56
78
46

72
105
87

>> O*P
ans =
2805
4692
2404

3480
5781
2980

3593
5988
3080

>> O.*P
ans =
264
1449
744

525
1716
1200

896
2106
1886

>> P-O
ans =
10 20
40 40
-7 -10

40
51
5

Federal Urdu university of arts science and technology

You might also like