ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

《DSP using MATLAB》Problem 2.3(Scilab脚本)

2022-02-16 12:31:07  阅读:133  来源: 互联网

标签:plot fontname get DSP xtilde1 MATLAB tilde 2.3 xtilde2


    只做了第4小题,放代码:

 1 // <<DSP using MATLAB>>3rd edition 
 2 // Book Author:Vinay K Ingle, John G Proakis
 3 //
 4 // Problem 2.3(4)
 5 // script by: 
 6 //
 7 clear, clc, clf();
 8 
 9 mode(2);
10 funcprot(0);
11 exec('fun_banner.sci');          // output version and OS info
12 //exec('fun_stepseq.sci');         // unit step sequence
13 exec('fun_sigadd.sci');          // sign sequence add/substract
14 
15 // ------------------------------------------------------------------------
16 //            START        Output Info about this sce-file                 
17 mprintf('\n***********************************************************\n');
18 [ban1,ban2] = fun_banner();
19 mprintf("\n     <DSP using MATLAB> 3rd edition, Problem 2.3(4)  \n");
20 mprintf(" ----------------------------------------------------------\n\n"); 
21 
22 // -----------END----------------------------------------------------------
23 
24 
25 //%%
26 //%% {...,1,2,3,...} + {...,1,2,3,4,...}     n=[0:24]
27 //%%      *                 *
28 //%%  what is the periods
29 
30 self_length1 = 3;
31 periods1 = 8;
32 
33 x1 = [1, 2, 3];
34 n1 = [0:(2+(periods1-1) * self_length1)];
35 xtilde1 = x1' * ones(1,periods1); xtilde1 = (xtilde1(:))';
36 
37 
38 self_length2 = 4;
39 periods2 = 6;
40 
41 n2 = [0:(3+(periods2-1) * self_length2)];
42 x2 = [1, 2, 3, 4];
43 xtilde2 = x2' * ones(1,periods2); xtilde2 = (xtilde2(:))';
44 
45 
46 //% x = xtilde1 + xtilde2
47 [x,n] = fun_sigadd(xtilde1, n1, xtilde2, n2);
48 
49 
50 f0=scf(0);                    //creates figure with id==0 and make it the current one
51 //  f.figure_size=[700,600];                // adjust window size
52 //  f.background=2;                         // add background color 8-white
53   f0.figure_name="Problem 2.3(4)";          // name window
54   subplot(3, 1, 1); 
55   plot(n1,xtilde1,'bo');
56   plot(n1,xtilde1,'b.');
57   plot2d3(n1,xtilde1,2);                      // Create plot with blue line
58 title("$Period\ Sequence\ \tilde{x_1}$",'fontname',7,'fontsize',4);
59 xlabel('n','fontname',3); ylabel('$\tilde{x_1}(n)$','fontname',3,'fontsize',3);
60 //xgrid();
61 xgrid(5,0,7);           // color, thickness, style
62 a0=get("current_axes");                // get the handle of the newly created axes
63 a0.data_bounds=[-0.1,24,-0.1,5];
64 
65 
66  subplot(3, 1, 2); 
67   plot(n2,xtilde2,'bo');
68   plot(n2,xtilde2,'b.');
69   plot2d3(n2,xtilde2,2);                      // Create plot with blue line
70 title("$Period\ Sequence\ \tilde{x_2}$",'fontname',7,'fontsize',4);
71 xlabel('n','fontname',3); ylabel('$\tilde{x_2}(n)$','fontname',3,'fontsize',3);
72 //xgrid();
73 xgrid(5,1,7);           // color, thickness, style
74 a1=get("current_axes");                // get the handle of the newly created axes
75 a1.data_bounds=[-0.1,24,-0.1,5];
76 
77 
78  subplot(3, 1, 3); 
79   plot(n,x,'bo');
80   plot(n,x,'b.');
81   plot2d3(n,x,2);                      // Create plot with blue line
82 title("$Period\ Sequence\ \tilde{x_1}+\tilde{x_2}$",'fontname',7,'fontsize',4);
83 xlabel('n','fontname',3); ylabel('x(n)','fontname',3);
84 //xgrid();
85 xgrid(5,1,7);           // color, thickness, style
86 a2=get("current_axes");                // get the handle of the newly created axes
87 a2.data_bounds=[-0.1,24,-0.1,8];
View Code

    运行结果:

    由上图可以看出,新序列的基本周期N=12。

 

标签:plot,fontname,get,DSP,xtilde1,MATLAB,tilde,2.3,xtilde2
来源: https://www.cnblogs.com/ky027wh-sx/p/15899937.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有