Lab 2 Sig
Lab 2 Sig
Object :
To understand the fundamental and commands of MATLAB.
Task 01:
>> Theta=45*pi/180
Theta =
0.7854
>> a=sin(Theta)
a=
0.7071
>> b=cos(Theta)
b=
0.7071
>> c=a^2+b^2
c=
>> a*b
ans =
0.5000
>> d=c+ans
d=
1.5000
>> A=6
A=
6
>> a=3
a=
>> c=A+a
c=
>> X='hello'
X=
hello
>> pi
ans =
3.1416
>> pi
ans =
3.1416
>> pi
ans =
3.1416
>> pi
ans =
3.141592653589793
>> pi
ans =
3.1416e+00
>> pi
ans =
3.141592653589793e+00
>> pi
ans =
3.14
>> pi
ans =
400921fb54442d18
BioIndexedFile - class allows random read access to text files using an index file.
fts2ascii - writes elements of time series data into a text (ASCII) file.
charhelp - This file contains help text strings for Financial Expo on line
htmlText - Add html editing tags to beginning and end of a text string.
menus_spb_timescope - Function to add context menus to the Time Scope block of DSP
System
cshelpengine - Context sensitive help engine used to launch the help browser.
Task 02:
a=3
a=
>> clear a
>> c=[0.3,8.5,6,-2.4]
c=
>> c(3)
ans =
6
>> c(4)
ans =
-2.4000
>> c=1:6
c=
1 2 3 4 5 6
>> b=0:2:1
b=
>> d=33:-1:-3
d=
Columns 1 through 12
33 32 31 30 29 28 27 26 25 24 23 22
Columns 13 through 24
21 20 19 18 17 16 15 14 13 12 11 10
Columns 25 through 36
9 8 7 6 5 4 3 2 1 0 -1 -2
Column 37
-3
>> e=0:pi/6:pi
e=
a=
1 3 5 7 9 11
>> b=[1 2 3 4 5 6]
b=
1 2 3 4 5 6
>> a.*b
ans =
1 6 15 28 45 66
>> a./b
ans =
>> a.\b
ans =
1.0000 0.6667 0.6000 0.5714 0.5556 0.5455
>> a.^b
ans =
>> 2.^a
ans =
>> a*.3
ans =
>> c=cos(a)
c=
0.5403 -0.9900 0.2837 0.7539 -0.9111 0.0044
>> b=[5;6;7;8]
b=
>> z=0:1:100
z=
Columns 1 through 12
0 1 2 3 4 5 6 7 8 9 10 11
Columns 13 through 24
12 13 14 15 16 17 18 19 20 21 22 23
Columns 25 through 36
24 25 26 27 28 29 30 31 32 33 34 35
Columns 37 through 48
36 37 38 39 40 41 42 43 44 45 46 47
Columns 49 through 60
48 49 50 51 52 53 54 55 56 57 58 59
Columns 61 through 72
60 61 62 63 64 65 66 67 68 69 70 71
Columns 73 through 84
72 73 74 75 76 77 78 79 80 81 82 83
Columns 85 through 96
84 85 86 87 88 89 90 91 92 93 94 95
>> size(z)
ans =
1 101
>> length(z)
ans =
101
>> a=1:4
a=
1 2 3 4
>> dot1=dot(a,b)
dot1 =
70
>> dotz=sum(a*b)
dotz =
70
>> s=sum(0)
s=
>> c=cumsum(a)
c=
1 3 6 10
>> p=prod(a)
p=
24
>> d=diff(a)
d=
1 1 1
>> [m,i]=max(a)
m=
i=
>> [m,i]=min(a)
m=
1
i=
>> [m,i]=min(a)
m=
i=
mean(a)
ans =
2.5000
>> median(a)
ans =
2.5000
>> sort(a)
ans =
1 2 3 4
>> sort(a,'descend')
ans =
4 3 2 1
Task 03;
A=[1 2 3;4 5 6;7 8 9]
A=
1 2 3
4 5 6
7 8 9
>> A(1,1)
ans =
>> A(3,2)
ans =
>> size(A)
ans =
3 3
>> A(:,3)
ans =
3
>> A(2,:)
ans =
4 5 6
B=
1 2 5
8 9 7
5 4 3
>> c=[A B]
c=
1 2 3 1 2 5
4 5 6 8 9 7
7 8 9 5 4 3