Digital Signal Processing Reference
In-Depth Information
>> Ztran = X'; % Calculates transpose of X
% Returns [2 4; 5 6]
>> Zinv = inv(X); % Inverts X
% Returns [-0.75 0.62; 0.50 -0.25]
>> Zarraymul = X.*Y; % Element by element multiplication
% Returns [2 25; 24 -12]
>> Zarraydiv = X./Y; % Element by element division
% Returns [2 1; 0.6667 -3]
>> Zpower1 = X. 2;
% Each element is raised to power
%by2
% Returns [4 25; 26 36]
>> Zpower2 = X. Y;
% Each element in X is raised to
% power by its corresponding
% element in Y
% Returns [2 3125; 4096 0.028]
E.5 Plotting functio ns
M ATLAB supports multidimensional visualization that allows experimental
data to be rendered graphically in a comprehensible format. In this section, we
will focus on 2D plots for continuous-time and discrete-time variables. Readers
should check the demo for more advanced graphics including 3D plots.
Example E.7
Plot the following function:
f [ k ] = 2 cos(0 . 5 k )
as a function of k for the range 20 k 20 .
Solution
The following set of M ATLAB instructions will generate and plot the function:
>> k = -20:20;
% Initializes k as a (1 x 41)
% row vector
>> f = 2*cos(0.5*k);
% Initializes f as cos(0.5k)
>> figure(1);
% selects figure 1 where plot
% is drawn
>> plot(k,f); grid on;
% CT plot of f (ordinate)
% versus k (abscissa)
% Grid is turned on
>> xlabel('k');
% Sets label of X-axis to k
>> ylabel('f[k]');
% Sets label of Y-axis to f[k]
>> axis([-25 25 -3 3])
% Plot is viewed in the range
% given by
Search WWH ::




Custom Search