Digital Signal Processing Reference
In-Depth Information
>>f=[14-23-2*i];
% initialize f
>> g = [-3 5+7*i 6 2];
% initialize g
>>r1=f+g
%Calculate the sum of f and g
% The result is displayed due
% to the absence of a
% semicolon at the end of the
% instruction
results in the following value for r1 :
r1 =
-2.0000 9.0000+7.0000i 4.0000 5.0000-2.0000i
which can be confirmed by direct addition of vectors f and g .
(ii) To compute part (ii), we use the M ATLAB function dot as follows:
>> r2 = dot(f,g)
% dot returns dot product btw f and g
which returns
r2 =
11.0000+32.0000i
An alternative approach to compute the dot product is to multiply the row vector
f by the conjugate transpose of g . The transpose is needed to make the two
vectors conformable for multiplication. You may verify that the instruction
>> r2 = g*f';
% alternative expression for calculating
% the dot product. Operator ' denotes
% complex-conjugate transpose
returns the same value as above.
(iii) The instruction for part (iii) is as follows:
>> r3 = sum(f)/length(f)
% sum(f) adds all row entries
% of vector f length(f)
% returns no. of entries in f
which returns
r3 =
1.5000 0.5000i
(iv) The instruction for part (iv) is as follows:
>> r4 = sum(f.*conj(f))/length(f)
% Operation f.*g does an element by
% element multiplication of vectors f
% and g. Operation conj(f) takes complex
% conjugate of each entry in f
Search WWH ::




Custom Search