Académique Documents
Professionnel Documents
Culture Documents
Electronic
Benghazi
Collage
Six term communication department
Homework 1
Digital Communication
laboratory
Mohammed A.A.Muftah
C-121031
Solutions:A (1) the result will be ass following:4^2-1
= 15
4^ (2-1) = 4
2\3
= 1.5
4*2-9/3 = 5
-3
=-3
>> 4^2-1
ans =
15
>> 4^ (2-1)
ans =
4
>> 2\3
ans =
1.5000
>> 4*2-9/3
ans =
5
>> -3
ans =
-3
"Command window of MATLAB"
Experiments:
>> a = fix (-2.5)
a=
-2
>> a = fix (2.5)
a=
2
>> a = fix (0.4)
a=
0
>> a = fix (0.7)
a=
0
>> b = floor (3.75)
b=
3
>> b = floor (-3.75)
b=
-4
>> b = floor (0.6)
b=
0
>> b = floor (-0.6)
b=
-1
>> c = ceil (-1.5)
c=
-1
>> c = ceil (1.5)
c=
2
>> c= ceil (0.3)
c=
1
>> c = ceil (-.07)
c=
0
>> d = round (2.25)
d=
2
>> d = round (-2.25)
d=
-2
>> d = round (-0.5)
d=
-1
>> d = round (0.5)
d=
1
"Command window MATLAB"
A (3) (a) The range of integers that can be stored as following:unit16: 0 65535
int16: -32768 32767
>> intmin ('uint16')
ans =
0
>> intmax ('uint16')
ans =
65535
>> intmin ('int16')
ans =
-32768
>> intmax ('int16')
ans =
32767
"Command window of MATLAB"
A (3) (b) Some assignment statement in variable types then changed it values and
types as below:>> character='A';
>> num=5;
>> logicVar=false;
>> num2=int16 (num);
>> whos
Name
Size
character
logicVar
num
num2
1x1
1x1
1x1
1x1
Bytes Class
2 char
1 logical
8 double
2 int16
>> character = 5;
>> num='Z';
>> logicVar=true;
>> num2=uint32 (character);
>> whos
Name
Size
Bytes Class
character
logicVar
num
num2
1x1
1x1
1x1
1x1
Attributes
Attributes
8 double
1 logical
2 char
4 uint32
"Command window of MATLAB"
A (6)
pv=2:2:8
pv (4) =33
pv (6) =11
Add value 11 to store in element sixth and fifth element filled in 0s
Prac=pv (3:5)
Great vector from third to fifth element"
linspace (4, 12, 3) Great a vector witch has 3 values linearly spaced from 4 to 12
including 4&12"
>> pv=2:2:8
pv =
2
6 33
6 33
0 11
8 12
"Command window of MATLAB"
A (7)
m= [1:4; 3 11 7 2] this function will make a matrix in first row it been from 1 to 4
(step=1) in second row it puts the ready row 3 11 7 2".
m (2,3) its show the element from column 2 and row 3.
m (:,3) its show the third column.
m(4) its show the element from colum2 an row 2.
size(m) it returns number of rows and columns of m matrix.
numel(m) show the number of elements for m matrix.
reshape(m,1,numel(m)) it reshape the matrix to row vector use first column,
second, third then forth column has same number of m element.
vec=m(1,:) make new vector use same values of first row from m matrix.
vec(2)=5 change the second value to sore 5.
vec(3) = [] delete the third element then numbered again.
vec(5) =8 store 8 in fifth and filled in forth element 0.
vec= [vec 11] add ll value to store in last element.
>> m= [1:4;3 11 7 2]
m=
1 2
3 11
>> m(2,3)
3
7
4
2
ans =
7
>> m(:,3)
ans =
3
7
>> m(4)
ans =
11
>> size(m)
ans =
2
>> numel(m)
ans =
8
>> reshape(m,1,numel(m))
ans =
1
2 11
>> vec=m(1,:)
vec =
1
>> vec(2)=5
vec =
1
>> vec(3)=[]
vec =
1
>> vec(5)=8
vec =
1
8 11
"Command window of MATLAB"