DSP using MATLAB示例Example3.18

代码:

% Analog Signal
Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t));

% Continuous-time Fourier Transform
Wmax = 2*pi*2000;
K = 500; k = 0:1:K;                             % index array k for frequencies
W = k*Wmax/K;                                   % freqency between 0 and +pi, [0,pi] axis divided into 501 points.
Xa = xa * exp(-j*t‘*W) * Dt; 

magXa  = abs(Xa);  angXa  = angle(Xa);  realXa  = real(Xa);  imagXa  = imag(Xa);
%% --------------------------------------------------------------------
%%              START Xa‘s  mag ang real imag
%% --------------------------------------------------------------------
figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Example3.18 Xa its mag ang real imag‘);
set(gcf,‘Color‘,‘white‘);
subplot(2,2,1); plot(W/pi,magXa); grid on;  %axis([0,1,0,1.5]);
title(‘Magnitude Response‘);
xlabel(‘frequency in \pi units‘); ylabel(‘Magnitude  |Xa|‘);
subplot(2,2,3); plot(W/pi, angXa/pi); grid on;  axis([-1,1,-1,1]);
title(‘Phase Response‘);
xlabel(‘frequency in \pi units‘); ylabel(‘Radians/\pi‘);

subplot(‘2,2,2‘); plot(W/pi, realXa); grid on;
title(‘Real Part‘);
xlabel(‘frequency in \pi units‘); ylabel(‘Real‘);
subplot(‘2,2,4‘); plot(W/pi, imagXa); grid on;
title(‘Imaginary Part‘);
xlabel(‘frequency in \pi units‘); ylabel(‘Imaginary‘);
%% -------------------------------------------------------------------
%%             END Xa‘s  mag ang real imag
%% -------------------------------------------------------------------

Xa = real(Xa);

W = [-fliplr(W), W(2:501)];                     % Omega from -Wmax to Wmax
Xa = [fliplr(Xa), Xa(2:501)];                   % Xa over -Wmax to Wmax interval

%% --------------------------------------------------------------------
%%
%% --------------------------------------------------------------------
figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘DSP MATLAB Example3.18‘);
set(gcf,‘Color‘,‘white‘);
subplot(2,1,1); plot(t*1000,xa); grid on;  %axis([0,1,0,1.5]);
title(‘Analog Signal‘);
xlabel(‘t in msec units.‘); ylabel(‘xa(t)‘);
subplot(2,1,2); plot(W/(2*pi*1000), Xa*1000); grid on; % axis([-1,1,-1,1]);
title(‘Continuous-time Fourier Transform‘);
xlabel(‘frequency in KHz‘); ylabel(‘Xa(jW)*1000‘);

%% -------------------------------------------------------------------
%%
%% -------------------------------------------------------------------

  运行结果:

时间: 2024-10-02 14:19:12

DSP using MATLAB示例Example3.18的相关文章

DSP using MATLAB 示例Example3.21

代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nTs)); Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nTs)); % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = x * sinc(Fs*

DSP using MATLAB 示例 Example3.19

代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signal Ts = 0.0002; n = -25:1:25; x = exp(-1000*abs(n*Ts)); % Discrete-time Fourier Transform %Wmax = 2*pi*2000; K = 500; k = 0:1:K; w = pi*k/K; % index ar

DSP using MATLAB示例Example3.16

代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, -0.2781]; % filter coefficient array a m = 0:length(b)-1; l = 0:length(a)-1; % index arrays m and l K = 500; k = 0:1:K; % index array k for frequenci

DSP using MATLAB 示例 Example3.15

上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figure('NumberTitle', 'off', 'Name', 'Input and Output sequence'); set(gcf,'Color','white'); subplot(2,1,1); stem(n,x); title('Input sequence'); xlabel('n'

DSP using MATLAB 示例Example3.17

DSP using MATLAB示例Example3.6

代码: n = [-5:5]; x = (-0.9).^n; % x(n) = k = -200:200; w = (pi/100)*k; % [0,pi] axis divided into 101 points. X = x * (exp(-j*pi/100)) .^ (n'*k); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); set(gcf,'Color','white'); subplot(2,2,1

DSP using MATLAB 示例Example3.9

用到的性质 上代码: n = 0:100; x = cos(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , [0,pi] axis divided into 101 points. X = x * (exp(-j*pi/100)) .^ (n'*k); % DTFT of x % signal multiplied y = exp(j*pi*n/4) .* x; % signal multiplied

DSP using MATLAB 示例Example3.7

上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points. X1 = x1 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x1 X2 = x2 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x2 x = alpha *

DSP using MATLAB 示例Example3.1 3.2 3.3

上代码: w = [0:1:500]*pi/500; % [0,pi] axis divided into 501 points. X = exp(j*w) ./ (exp(j*w) - 0.5*ones(1,501)); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi,magX); grid on; titl