《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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值