《DSP using MATLAB》Problem 2.6

本文通过四个示例展示了如何使用MATLAB进行信号序列的分解,包括分离信号的偶数部分和奇数部分,并通过图表直观地展示原始信号及分解后的结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

  运行结果:

 

转载于:https://www.cnblogs.com/ky027wh-sx/p/7967348.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值