% ***** MATLAB Code Starts Here %
%Z_TRANSFORM_01_MAT
%
T = pi/10;
% Sample period, secondsws = 2*pi/T;
% Sample frequency, r/s%
w1 = 2; w2 = 22;
% Frequencies to be studied%
% Plot the s-plane with the primary strip defined by the imaginary axis
% ranging from -jws/2 to +jws/2 and the two test frequencies, w1 and w2,
% identified.
%
fig_size = [232 84 774 624];
figure(1),clf,plot(0,w1,
'bo',0,w2,'rx',[-25 25],[ws/2 ws/2],'r:',[-25 25],[-ws/2 -ws/2],'r:')axis(
'square'),axis([-25 25 -25 25]),plotax,xlabel('Real Axis'),ylabel('Imag Axis'),...title(
's-Plane with T = pi/10 s'),set(gcf,'Position',fig_size),...text(1,w1,[
'w_1 = ' int2str(w1) ' r/s']),text(1,w2,['w_2 = ' int2str(w2) ' r/s']),...text(-18,11,
'w_s/2'),text(-18,-9,'-w_s/2')%
% Define the unit circle for use in the z-plane using the function "circle"
% which is provided at the end of this file.
%
[xx,yy] = circle;
%
% Define the points in the s-plane and the z-plane corresponding to the
% test frequencies w1 and w2 and the value of the sampling period T.
%
s1 = j*w1; s2 = j*w2;
z1 = exp(s1*T); z2 = exp(s2*T);
%
% Plot the z-plane with the unit circle and the mappings of the frequencies
% w1 and w2 into the z-plane with the period T.
%
figure(2),clf,
...plot(xx,yy,
'k',real(z1),imag(z1),'bo',real(z2),imag(z2),'rx'),grid,...xlabel(
'Real Axis'),ylabel('Imag Axis'),title('z-Plane with T = pi/10 s'),...axis(
'square'),axis([-2 2 -2 2]),... set(gcf,'Position',fig_size)text(0.9,0.6,
'z_1 = z_2'),text(-0.95,1.4,'z = exp(s*T)'),...text(-0.95,1.2,
'z_1 = z_2 = 0.8090 + j0.5878')%
% Compute the continuous-time functions x1(t) and x2(t) corresponding to
% the frequencies w1 and w2, respectively. Compute the values of those
% functions at the sample points separated by T.
%
ts = 0:T:5; t = 0:.01:5;
x1 = cos(w1*t); x2 = cos(w2*t);
x1s = cos(w1*ts); x2s = cos(w2*ts);
%
% Plot the two time functions and their sample values.
%
figure(3),clf,stem(ts,x1s);grid,hold on,plot(t,x1,
'k:',t,x2,'r:'),...hold off,xlabel(
'Time (s)'),ylabel('Amplitude'),...title(
'x_1(t)=cos(2*t) and x_2(t)=cos(22*t) sampled at T = pi/10 s'),... set(gcf,'Position',fig_size)%
% Calculate the first several frequencies which appear when the two
% signals x1(t) and x2(t) are sampled with a sampling period T.
%
n = [-1 0 1];
w1 = [-w1 w1]; w2 = [-w2 w2];
%
wx1 = []; wx2 = [];
for i = 1:length(n)wx1 = [wx1 (w1 - n(i)*ws)];
wx2 = [wx2 (w2 - n(i)*ws)];
end
%
wx1 = sort(wx1);wx2 = sort(wx2);
clear i
%
% % ***** MATLAB Code Stops Here
Click the
icon to return to the Dr. Beale's home page
Latest revision on 05/07/01 12:22 PM