c3ex4.m

来自「数字信号处理Matlab实现?中藕糯鞰atlab实现数字信号处理Matlab」· M 代码 · 共 17 行

M
17
字号
%	Program to give partial Fourier sums of an %	odd square wave of unit amplitude%n_max = input('Enter vector of highest harmonic values desired (odd) ');N = length(n_max);t = 0:.002:1;omega_0 = 2*pi;for k = 1:N	n = [];	n = [1:2:n_max(k)];	b_n = 4./(pi*n);		% Form vector of Fourier sine-coefficients	x = b_n*sin(omega_0*n'*t);	% Rows of sine matrix are versus time; columns are versus n,					% so matrix multiply sums over n	subplot(N,1,k),plot(t, x), xlabel('t'), ylabel('partial sum'),...	axis([0 1 -1.5 1.5]), text(.05,-.5, ['max. har. = ', num2str(n_max(k))])end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?