📄 comp_exam2_1.m
字号:
% Plot of line spectra for half-rectified sinewave
%
clf
A = 1;
n_max = 11; % Maximum harmonic plotted; odd
n = -n_max:1:n_max;
X = A./(pi*(1+eps - n.^2)); % Offset 1 slightly to avoid divide by 0
for m = 1:2:2*n_max+1
X(m) = 0; % Set odd harmonic lines to 0
end
X(n_max+2) = -j*A/4; % Compute lines for n = 1 & n = -1
X(n_max) = j*A/4;
[arg_X, mag_X] = cart2pol(real(X),imag(X)); % Convert to magnitude and phase
for m = n_max+3:2:2*n_max+1
arg_X(m) = arg_X(m) - 2*pi; % Force phase to be odd
end
subplot(2,1,1),stem(n, mag_X),ylabel('|X_n|')
title('Plot of amplitude and phase spectra for half-rectified sinewave')
subplot(2,1,2),stem(n, arg_X),xlabel('nf_0'),ylabel('angle(X_n)')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -