《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] = version;
fprintf(‘    MATLAB Version: %20s\n\n‘, v);
fprintf(‘     Released Date: %17s\n\n‘, d);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Today is %7s, and Now is %20s   \n\n‘, wkd2, time_stamp);
%% ------------------------------------------------------------------------

n = [0:9];
%x = stepseq(0,0,10) - stepseq(10,0,10);
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
[xe,xo,m] = evenodd(x,n);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色
stem(n,x); title(‘x sequence ‘);
xlabel(‘n‘); ylabel(‘x(n)‘) ;
% axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])
stem(m,xe); title(‘Even Part‘);
xlabel(‘n‘); ylabel(‘xe(n)‘);
%axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,‘white‘)
stem(m,xo); title(‘Odd Part‘);
xlabel(‘n‘); ylabel(‘xo(n)‘);
%axis([-10,10,-0.6,0.6])
grid on

  运行结果:

2、代码

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

[v, d] = version;
fprintf(‘    MATLAB Version: %20s\n\n‘, v);
fprintf(‘     Released Date: %17s\n\n‘, d);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Today is %7s, and Now is %20s   \n\n‘, wkd2, time_stamp);
%% ------------------------------------------------------------------------

n = [-5:10];
x = exp(0.1 * n) .* (stepseq(-5,-5,10) - stepseq(10,-5,10)); 

[xe,xo,m] = evenodd(x,n);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色
stem(n,x); title(‘x sequence ‘);
xlabel(‘n‘); ylabel(‘x(n)‘) ;
% axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])
stem(m,xe); title(‘Even Part‘);
xlabel(‘n‘); ylabel(‘xe(n)‘);
%axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,‘white‘)
stem(m,xo); title(‘Odd Part‘);
xlabel(‘n‘); ylabel(‘xo(n)‘);
%axis([-10,10,-0.6,0.6])
grid on

  运行结果:

3、代码

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

[v, d] = version;
fprintf(‘    MATLAB Version: %20s\n\n‘, v);
fprintf(‘     Released Date: %17s\n\n‘, d);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Today is %7s, and Now is %20s   \n\n‘, wkd2, time_stamp);
%% ------------------------------------------------------------------------

n = [-20:20];
x = cos(0.2 * pi * n + pi/4); 

[xe,xo,m] = evenodd(x,n);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色
stem(n,x); title(‘x sequence ‘);
xlabel(‘n‘); ylabel(‘x(n)‘) ;
% axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])
stem(m,xe); title(‘Even Part‘);
xlabel(‘n‘); ylabel(‘xe(n)‘);
%axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,‘white‘)
stem(m,xo); title(‘Odd Part‘);
xlabel(‘n‘); ylabel(‘xo(n)‘);
%axis([-10,10,-0.6,0.6])
grid on

  运行结果:

4、代码

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

[v, d] = version;
fprintf(‘    MATLAB Version: %20s\n\n‘, v);
fprintf(‘     Released Date: %17s\n\n‘, d);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Today is %7s, and Now is %20s   \n\n‘, wkd2, time_stamp);
%% ------------------------------------------------------------------------

n = [0:100];
x = exp(-0.05 * n) .* sin(0.1 * pi * n + pi/3); 

[xe,xo,m] = evenodd(x,n);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色
stem(n,x); title(‘x sequence ‘);
xlabel(‘n‘); ylabel(‘x(n)‘) ;
% axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,[1,1,1])
stem(m,xe); title(‘Even Part‘);
xlabel(‘n‘); ylabel(‘xe(n)‘);
%axis([-10,10,0,1.2])
grid on

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.6‘)
set(gcf,‘Color‘,‘white‘)
stem(m,xo); title(‘Odd Part‘);
xlabel(‘n‘); ylabel(‘xo(n)‘);
%axis([-10,10,-0.6,0.6])
grid on

  运行结果:

时间: 2024-10-03 14:38:48

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

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