代码:
%% ---------------------------------------------------------------------------- %% Output Info about this m-file fprintf(‘\n***********************************************************\n‘); fprintf(‘ <DSP using MATLAB> Problem 4.8 \n\n‘); banner(); %% ---------------------------------------------------------------------------- %% ----------------------------------------------------- %% x3(n)=x1(n)*x2(n) %% sigma(x3)=[sigma(x1)] [sigma(x2)] %% ----------------------------------------------------- num = 10; x1 = 0 + (2-0)*rand(1, 2*num+1); n1 = [-num:num]; sum_x1 = sum(x1(:)) x2 = 0 + (2-0)*rand(1, 2*num+1); n2 = [-num:num]; sum_x2 = sum(x2(:)) figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 4.8 Sequence x1 and x2‘); set(gcf,‘Color‘,‘white‘); %hist(x1,x_axis); subplot(2,1,1); stem(n1, x1); title(‘Uniformly Distributed Random Numbers x1(n)‘); xlabel(‘n‘); ylabel(‘x1(n)‘); grid on; subplot(2,1,2); stem(n2, x2); title(‘Uniformly Distributed Random Numbers x2(n)‘); xlabel(‘n‘); ylabel(‘x2(n)‘); grid on; [x3, n3] = conv_m(x1, n1, x2, n2); sum_x3 = sum(x3(:)) sum_chk = sum_x1 * sum_x2 figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 4.8 Sequence x3‘); set(gcf,‘Color‘,‘white‘); %hist(x1,x_axis); %subplot(2,1,1); stem(n3, x3); title(‘Sequence x3(n)=x1*x2 ‘); xlabel(‘n‘); ylabel(‘x3(n)‘); grid on;
运行结果:
原文地址:https://www.cnblogs.com/ky027wh-sx/p/8436672.html
时间: 2024-11-06 03:54:28