《DSP using MATLAB》Problem 5.7

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Problem 5.7 \n\n‘);

banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

% --------------------------------------------------
%        1  x(n) = [ 2,4,6,1,3,5 ]    N--period
%                    |
% --------------------------------------------------
x = [2, 4, 6, 1, 3, 5]; N = 6; n = [0 : N-1];              % periodic sequence with period N
y = x( mod(-n, N)+1 );                                     % circular fold

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘P5.7 x(n) and x(-n)‘)
set(gcf,‘Color‘,‘white‘);
subplot(2,1,1); stem(n, x);
xlabel(‘n‘); ylabel(‘x(n)‘);
title(‘$\tilde x(n) sequence, period N=6$‘, ‘interpreter‘, ‘latex‘, ‘fontsize‘, 14);  grid on;
subplot(2,1,2); stem(n, y);
xlabel(‘n‘); ylabel(‘y(n)‘);
title(‘x(-n) sequence‘);  grid on;

%% ------------------------------------------------------------------
%%                 DFS(k) of xn sequence, k=[0:N-1], N=6
%% ------------------------------------------------------------------
k1 = [0 : length(x)-1];
%k2 = [-N : N-1];
%k3 = [-N/2 : N/2];
Xk_1 = dfs(x, N);                                         % DFS
magXk = abs( [ Xk_1 ] );          % DFS magnitude
angXk = angle( [Xk_1] )/pi;       % DFS angle

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘P5.7 DFS(k) of x(n)‘)
set(gcf,‘Color‘,‘white‘);
subplot(2,1,1); stem(k1, magXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘k‘); ylabel(‘magnitude(k)‘);
title(‘DFS magnitude of x(n), N=6‘);  grid on;
subplot(2,1,2); stem(k1, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘k‘); ylabel(‘angle(k)‘);
title(‘DFS angle of x(n), N=6‘);  grid on;

%% ------------------------------------------------------------------
%%                 DFS(k) of yn sequence, k=[0:N-1], N=6
%% ------------------------------------------------------------------
k1 = [0 : length(y)-1];
%k2 = [-N : N-1];
%k3 = [-N/2 : N/2];
Yk_1 = dfs(y, N);                 % DFS
magYk = abs( [ Yk_1 ] );          % DFS magnitude
angYk = angle( [Yk_1] )/pi;       % DFS angle

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘P5.7 DFS(k) of y(n)‘)
set(gcf,‘Color‘,‘white‘);
subplot(2,1,1); stem(k1, magYk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘k‘); ylabel(‘magnitude(k)‘);
title(‘DFS magnitude of y(n), N=6‘);  grid on;
subplot(2,1,2); stem(k1, angYk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘k‘); ylabel(‘angle(k)‘);
title(‘DFS angle of y(n), N=6‘);  grid on;

  运行结果:

周期序列及其圆周折叠序列:

原始序列的DFS系数

圆周折叠序列的DFS系数

原文地址:https://www.cnblogs.com/ky027wh-sx/p/9314201.html

时间: 2024-11-12 02:51:39

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

《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,