码迷,mamicode.com
首页 > 其他好文 > 详细

《DSP using MATLAB》第2章习题Problem2.1

时间:2017-11-11 22:55:45      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:time   title   ***   img   fonts   output   运行   .com   amp   

技术分享

1、代码:

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

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

n1 = -5; n2 = 15;
n = [n1:n2];
x1 = 3 * impseq(-2,n1,n2) + 2 * impseq(0,n1,n2) - impseq(3,n1,n2) + 5 * impseq(7,n1,n2);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.1‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x1); title(‘x1 Sequence‘);
xlabel(‘$n$‘, ‘interpreter‘, ‘latex‘, ‘fontsize‘, 15); 
ylabel(‘x1(n)‘, ‘fontsize‘, 15); grid on;

  运行结果:

技术分享

2、代码:

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

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

n1 = -10; n2 = 10;
n = [n1:n2];
x2 = exp(-5) * impseq(-10,n1,n2) + exp(-4) * impseq(-8,n1,n2) + exp(-3)*impseq(-6,n1,n2);
x2 = x2 + exp(-2)*impseq(-4,n1,n2) + exp(-1)*impseq(-2,n1,n2) + exp(0) * impseq(0,n1,n2);
x2 = x2 + exp(-1)*impseq(2,n1,n2) + exp(-2)*impseq(4,n1,n2) + exp(-3)*impseq(6,n1,n2);
x2 = x2 + exp(-4)*impseq(8,n1,n2) + exp(-5)*impseq(10,n1,n2);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.2‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x2); title(‘x2 Sequence‘);
xlabel(‘n‘); ylabel(‘x2(n)‘); grid on;

  运行结果:

技术分享

3、代码:

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

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


n1 = -5; n2 = 25;
n = [n1:n2];
x3 = 10*stepseq(0,n1,n2) + (-5)*stepseq(5,n1,n2) + (-10)*stepseq(10,n1,n2)+ 5*stepseq(15,n1,n2);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.3‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x3); title(‘x3 Sequence‘);
xlabel(‘n‘); ylabel(‘x3(n)‘); grid on;

  运行结果:

技术分享

4、代码:

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

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



n1 = -30; n2 = 30;
n = [n1:n2];
x4 = exp(0.1*n) .* stepseq(-20,n1,n2) - exp(0.1*n) .* stepseq(10,n1,n2);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.4‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x4); title(‘x4 Sequence‘);
xlabel(‘n‘); ylabel(‘x4(n)‘); grid on;

  运行结果:

技术分享

5、代码:

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

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


n1 = -200; n2 = 200;
n = [n1:n2];
x5 = 5*(cos(0.49*pi*n) + cos(0.51*pi*n));


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.5‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x5); title(‘x5 Sequence‘);
xlabel(‘n‘); ylabel(‘x5(n)‘); grid on;

  运行结果:

技术分享

6、代码:

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

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


n1 = -200; n2 = 200;
n = [n1:n2];
x6 = 2 * cos(0.01*pi*n) .* cos(0.5*pi*n);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.6‘)
set(gcf,‘Color‘,‘white‘); 
stem(n,x6); title(‘x6 Sequence‘);
xlabel(‘n‘); ylabel(‘x6(n)‘); grid on;

  运行代码:

技术分享

7、代码:

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

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

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


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.7‘);
set(gcf,‘Color‘,‘white‘); 
stem(n,x7); title(‘x7 Sequence‘);
xlabel(‘n‘); ylabel(‘x7(n)‘); grid on;

  运行结果:

技术分享

8、代码:

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

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

n1 = 0; n2 = 100;
n = [n1:n2];
x8 = exp(0.01*n) .* sin(0.1*pi*n);


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.1.8‘);
set(gcf,‘Color‘,‘white‘); 
stem(n,x8); title(‘x8 Sequence‘);
xlabel(‘n‘); ylabel(‘x8(n)‘); grid on;

  运行结果:

技术分享

 

《DSP using MATLAB》第2章习题Problem2.1

标签:time   title   ***   img   fonts   output   运行   .com   amp   

原文地址:http://www.cnblogs.com/ky027wh-sx/p/7820082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!