⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tonegen.m

📁 文件中包含"基于计算机的信号处理实践"这本书所有的程序代码,是基于MATLAB环境下开发的,使用者可根据自已的需要,改改!
💻 M
字号:
function  [y,code] = tonegen(digits, scale, yint)%TONEGEN      generate "mystery" signal containing tones%-------%   Usage:     [Y, C] = tonegen(D, S, Xint)%%        D : vector of digits for a 5-element code %            if length(D)<5, the function will pick random digits%        S : scale factor that multiplies the interference signal%     Xint : interference signal%        Y : output signal%        C : output code actually used%---------------------------------------------------------------% copyright 1994, by C.S. Burrus, J.H. McClellan, A.V. Oppenheim,% T.W. Parks, R.W. Schafer, & H.W. Schussler.  For use with the book% "Computer-Based Exercises for Signal Processing Using MATLAB"% (Prentice-Hall, 1994).%---------------------------------------------------------------if ( nargin < 3)   load intfere.mat   if ~exist('yint')       error(' problem loading interference')   endendif ( nargin < 2 )  scale = 1.0;    %--- add 100% interferenceendfsamp = 10000;tones = (250 + 500*[0:9]')/fsamp;if length(digits) < 5    digits = mod(fix(clock),10);  digits = digits(2:6);endcode = mod(fix(digits(1:5)),10);    %--- just 5 digits, must be intergers%----- rand('uniform')    %--- version 4LL = 50*rand(7,1)-25;    %---- variation in lengthsLL = fix(LL) + [55;175*ones(5,1);95];Ltot = sum(LL);if Ltot > length(yint)   LL = fix(LL*Ltot/length(yint));endttt = [0.5*rand(1);tones(code+1);0.5*rand(1)];   %--- create the tonesfor j = 1:7;   f1 = [ f1; ttt(j)*ones(LL(j),1) ];endN = length(f1);   Nm1 = N-1;   nn = [0:Nm1]';%--------------------tau = 0.8;[ttt,fli] = filter(1-tau,[1 -tau],f1(1)*ones(99,1));   %--- set init conds.f1 = filter(1-tau,[1 -tau],f1,0.9*fli);%---- rand('normal')    %--- version 4y = cos(2*pi*f1.*nn);y = y +scale*yint(1:N);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -