《DSP using MATLAB》Problem 4.8

代码:

%% ----------------------------------------------------------------------------
%%            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

《DSP using MATLAB》Problem 4.8的相关文章

《DSP using MATLAB》 Problem 2.3

本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.3.1 \

《DSP using MATLAB》Problem 2.5

2.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.5.2 \n\n'); time_st

《DSP using MATLAB》Problem 2.6

1.代码 %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.6.1 \n\n'); [v, d] =

《DSP using MATLAB》Problem 2.8

1.代码: 从MATLAB官方网上下载的. %*************************************************************************% %A code for the Downsampler% %Author: Yashwant Marathe% %Date:20-12-2010% function [y ny] = dnsample(x,n,M) %x is a sequence over indices specified by v

《DSP using MATLAB》Problem 2.14

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.14 \n\n'); banner();

《DSP using MATLAB》Problem 2.16

先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Prob

《DSP using MATLAB》Problem 2.15

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.15 \n\n'); banner();

《DSP using MATLAB》Problem 2.19

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.19 \n\n'); banner();

《DSP using MATLAB》Problem 2.20

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.20 \n\n'); banner();

《DSP using MATLAB》Problem 3.1

先写DTFT子函数: function [X] = dtft(x, n, w) %% ------------------------------------------------------------------------ %% Computes DTFT (Discrete-Time Fourier Transform) %% of Finite-Duration Sequence %% Note: NOT the most elegant way % [X] = dtft(x, n,