




文檔簡(jiǎn)介
1、function y = wgn(varargin)%WGN Generate white Gaussian noise.% Y = WGN(M,N,P) generates an M-by-N matrix of white Gaussian noise.% P specifies the power of the output noise in dBW.% Y = WGN(M,N,P,IMP) specifies the load impedance in Ohms.% Y = WGN(M,N,P,IMP,STATE) resets the state of RANDN to STATE.
2、% Additional flags that can follow the numeric arguments are:% Y = WGN(., POWERTYPE) specifies the units of P. POWERTYPE can% be dBW, dBm or linear. Linear power is in Watts.% Y = WGN(., OUTPUTTYPE); Specifies the output type. OUTPUTTYPE can% be real or complex. If the output type is complex, then P
3、% is divided equally between the real and imaginary components.% Example 1: % % To generate a 1024-by-1 vector of complex noise with power% % of 5 dBm across a 50 Ohm load, use:% Y = wgn(1024, 1, 5, 50, dBm, complex)% Example 2: % % To generate a 256-by-5 matrix of real noise with power% % of 10 dBW
4、 across a 1 Ohm load, use:% Y = wgn(256, 5, 10, real)% Example 3: % % To generate a 1-by-10 vector of complex noise with power% % of 3 Watts across a 75 Ohm load, use:% Y = wgn(1, 10, 3, 75, linear, complex)% See also RANDN, AWGN. % Copyright 1996-2008 The MathWorks, Inc.% $Revision: 1.11.4.5 $ $Dat
5、e: 2008/08/01 12:17:45 $ % - Initial checkserror(nargchk(3,7,nargin,struct); % - Value set indicators (used for the strings)pModeSet = 0;cplxModeSet = 0; % - Set default valuesp = ;row = ;col = ;pMode = dbw;imp = 1;cplxMode = real;seed = ; % - Placeholders for the numeric and string index valuesnumA
6、rg = ;strArg = ; % - Identify string and numeric arguments% An empty in position 4 (Impedance) or 5 (Seed) are considered numericfor n=1:nargin if(isempty(vararginn) switch n case 4 if(ischar(vararginn) error(comm:wgn:InvalidDefaultImp,The default impedance should be marked by .); end; vararginn = i
7、mp; % Impedance has a default value case 5 if(ischar(vararginn) error(comm:wgn:InvalidNumericInput,The default seed should be marked by .); end; vararginn = ; % Seed has no default otherwise vararginn = ; end; end; % - Assign the string and numeric vectors if(ischar(vararginn) strArg(size(strArg,2)+
8、1) = n; elseif(isnumeric(vararginn) numArg(size(numArg,2)+1) = n; else error(comm:wgn:InvalidArg,Only string and numeric arguments are allowed.); end;end; % - Build the numeric argument setswitch(length(numArg) case 3 % - row is first (element 1), col (element 2), p (element 3) if(all(numArg = 1 2 3
9、) row = vararginnumArg(1); col = vararginnumArg(2); p = vararginnumArg(3); else error(comm:wgn:InvalidSyntax,Illegal syntax.) end; case 4 % - row is first (element 1), col (element 2), p (element 3), imp (element 4) % if(all(numArg(1:3) = 1 2 3) row = vararginnumArg(1); col = vararginnumArg(2); p =
10、vararginnumArg(3); imp = vararginnumArg(4); else error(comm:wgn:InvalidSyntax,Illegal syntax.) end; case 5 % - row is first (element 1), col (element 2), p (element 3), imp (element 4), seed (element 5) if(all(numArg(1:3) = 1 2 3) row = vararginnumArg(1); col = vararginnumArg(2); p = vararginnumArg(
11、3); imp = vararginnumArg(4); seed = vararginnumArg(5); else error(comm:wgn:InvalidSyntax,Illegal syntax.); end; otherwise error(comm:wgn:InvalidSyntax,Illegal syntax.);end; % - Build the string argument setfor n=1:length(strArg) switch lower(vararginstrArg(n) case dbw dbm linear if(pModeSet) pModeSe
12、t = 1; pMode = lower(vararginstrArg(n); else error(comm:wgn:TooManyPowerTypes,The Power mode must only be set once.); end; case db error(comm:wgn:InvalidPowerType,Incorrect power mode passed in. Please use dBW, dBm, or linear.); case real complex if(cplxModeSet) cplxModeSet = 1; cplxMode = lower(var
13、arginstrArg(n); else error(comm:wgn:TooManyOutputTypes,The complexity mode must only be set once.); end; otherwise error(comm:wgn:InvalidArgOption,Unknown option passed in.); end;end; % - Arguments and defaults have all been set, either to their defaults or by the values passed in% so, perform range
14、 and type checks % - pif(isempty(p) error(comm:wgn:InvalidPowerVal,The power value must be a real scalar.);end; if(any(isreal(p) (length(p)1) (length(p)=0) error(comm:wgn:InvalidPowerVal,The power value must be a real scalar.);end; if(strcmp(pMode,linear) if(p= 0.); end;end; % - Dimensionsif(any(ise
15、mpty(row) isempty(col) isscalar(row) isscalar(col) error(comm:wgn:InvalidDims,The required dimensions must be real, integer scalars 1.);end; if(any(row=0) (col 1.);end; % - Impedanceif(any(isreal(imp) (length(imp)1) (length(imp)=0) any(imp 0.);end; % - Seedif(isempty(seed) if(any(isreal(seed) (length(seed)1) (length(seed)=0) any(seed-floor(seed)=0) error(comm:wgn:InvalidState,The State must be a real, integer scalar.); end;end; % - All parameters are valid, so no extra checking is requiredswitch lower(pMode) case linear noisePower = p; case dbw noisePower = 10(p/10); case dbm
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2 學(xué)會(huì)寬容(教學(xué)設(shè)計(jì))-2023-2024學(xué)年統(tǒng)編版道德與法治六年級(jí)下冊(cè)
- 2 落花生 教學(xué)設(shè)計(jì)-2024-2025學(xué)年統(tǒng)編版語(yǔ)文五年級(jí)上冊(cè)
- 5小小的船 教學(xué)設(shè)計(jì)-2024-2025學(xué)年語(yǔ)文一年級(jí)上冊(cè)統(tǒng)編版
- 8 匆匆 教學(xué)設(shè)計(jì)-2023-2024學(xué)年語(yǔ)文六年級(jí)下冊(cè)統(tǒng)編版
- 演出策劃服務(wù)合同合同范本
- 工程傷亡合同范本
- 4 田家四季歌(教學(xué)設(shè)計(jì))2024-2025學(xué)年統(tǒng)編版語(yǔ)文二年級(jí)上冊(cè)
- 酒店出租專車合同范本
- Module 5 Museums Unit 3 教學(xué)設(shè)計(jì) 2024-2025學(xué)年外研版九年級(jí)英語(yǔ)上冊(cè)
- 5《應(yīng)對(duì)自然災(zāi)害》(教學(xué)設(shè)計(jì))2023-2024學(xué)年統(tǒng)編版道德與法治六年級(jí)下冊(cè)
- 小學(xué)英語(yǔ)外研版(三起點(diǎn))四年級(jí)下冊(cè)全冊(cè)課文翻譯(1-10模塊)
- WS 400-2023 血液運(yùn)輸標(biāo)準(zhǔn)
- 銀行業(yè)金融機(jī)構(gòu)監(jiān)管數(shù)據(jù)標(biāo)準(zhǔn)化規(guī)范(2021版)數(shù)據(jù)結(jié)構(gòu)一覽表
- 電子商務(wù)基礎(chǔ)與實(shí)務(wù)(第四版)高職PPT完整全套教學(xué)課件
- 信息論與編碼(第4版)完整全套課件
- 施工吊籃工程監(jiān)理實(shí)施細(xì)則
- 自動(dòng)扶梯與自動(dòng)人行道調(diào)試作業(yè)指導(dǎo)書(shū)(通用版)
- 2023年全國(guó)卷英語(yǔ)甲卷講評(píng)課件-2024屆高考英語(yǔ)復(fù)習(xí)
- 現(xiàn)代通信原理與技術(shù)(第五版)PPT全套完整教學(xué)課件
- 《戰(zhàn)勝抑郁 走出抑郁癥的30天自我康復(fù)訓(xùn)練》讀書(shū)筆記思維導(dǎo)圖
- 幼兒園課件:時(shí)鐘國(guó)王
評(píng)論
0/150
提交評(píng)論