2FSK信號的調(diào)制與解調(diào)matlab程序_第1頁
2FSK信號的調(diào)制與解調(diào)matlab程序_第2頁
2FSK信號的調(diào)制與解調(diào)matlab程序_第3頁
2FSK信號的調(diào)制與解調(diào)matlab程序_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、clear all;close all;f = 300;t = 2*(0:0.001:1-0.01)/f;x = t;singal= sin(2*pi*f*x)+1;% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % u率PCM編碼 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % a = singal;n = 8;%u率非線性u = 255;%待考察,應(yīng)該是255%c = zeros(size(a);for i = 1:leng

2、th(a) c(i) = log(1+u*a(i)/log(1+u); %在PCM中要求x應(yīng)該大于0endcmax = max(c);cmin = min(c);%均勻量化c_quan = c;b_quan = c_quan;d = (cmax - cmin)/n; %此處有問題% % % % % % % % % % % % % % % 自己寫的量化代碼% % % % % % % % % % % %for j = 1:n+1 kk(j) = cmin + j*d;endfor k = 1:n q(k) = (kk(k)+kk(k+1)/2;end% % % % % % % % % % % %

3、% % % % % % % % % % % % % % % % % % % % % % % for i = 1:n m = find(q(i)-d/2 <= c_quan) & (q(i)+d/2 >= c_quan); c_quan(m) = q(i).*ones(1,length(m); b_quan(find(c_quan=q(i) = (i-1).* ones(1,length(find(c_quan=q(i);end% 編碼nu = ceil(log2(n);code = zeros(length(a),nu);for i = 1:length(a) for j

4、= (nu-1):-1:0 if (fix(b_quan(i)/(2j)=1) code(i,(nu-j) = 1; b_quan(i) = b_quan(i)-2j; end endendbitstorm = ;for i = 1:length(code) bitstorm = bitstorm,code(i,:);end% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % FSK調(diào)制的實現(xiàn)% % % % % % % % % % % % % % % % % % % % % % %

5、 % % % % % % % % % % % % % % % % % % figure(1)subplot(221);stairs (bitstorm(1:20);title('調(diào)制信號');axis(0,20,-0.1,1.2);grid on% % % % % % % % % % % % %這是設(shè)置隨機(jī)數(shù)值 % % % % % % % % % % % % % % % % % % % % % % % rand('state',sum(100*clock);randn('state',sum(100*clock);mintestlongth =

6、1000;maxtestlongth = 1000;A = 1;Eb = A * A;SNR = 10; %信噪比index = 1;% for SNR1 = 0:10 disp ('程序在運行,請稍等.'); N0 = Eb * 10(-SNR/10);%待解決 noiseVar = N0/2;%噪聲密度 noiseRoot = sqrt(noiseVar) % 噪聲的均方差 errorCount = 0; testCount = 0; f1 = 1; f2 = 2; mm = 0:0.02:1-0.02;%抽樣判決在t軸上的抽樣矩陣 i = 0; DemoFSK = zer

7、os(1,mintestlongth); FSK = zeros(1,10*length(mm); %這是為什么 noise_FSK = zeros(1,10*length(mm); while (1) i = i +1;% % % % % % % % % % % % % % % % % % % % 調(diào)制解調(diào) src = bitstorm(i); src1 = src; src2 = 1-src; noise = noiseRoot.*randn(1,length(noiseRoot);%高斯白噪聲矩陣 fsk = cos(2*pi*f1*mm)*src1 + cos(2*pi*f2*mm)*

8、src2; noise_fsk = fsk + noise; if i <= 10 FSK(1+length(mm)*(i-1):length(mm)*i) = fsk; %修改過% noise_FSK(1+length(mm)*(i-1):length(mm)*i) = noise_fsk; end ofsk1 = noise_fsk.* cos(2*pi*f1*mm); ofsk2 = noise_fsk.* cos(2*pi*f2*mm); ofsk11 = filtfilt(ones(1,10),9.7675,ofsk1);% 低通濾波 ofsk22 = filtfilt(one

9、s(1,10),9.7675,ofsk2); avo1 = sum(abs(ofsk11)/length(mm);% 抽樣值的絕對值的平均值 avo2 = sum(abs(ofsk22)/length(mm); if avo1 >= 1/2 DemoFSK(i) = 1; else DemoFSK(i) = 0; end if avo1>1/2 & avo2 >1/2 errorCount = errorCount + 1; elseif avo1<1/2 & avo2 <1/2 errorCount = errorCount + 1; end t

10、estCount = testCount + 1; %測試的長度 if (testCount < mintestlongth) % 判斷測試長度是否達(dá)到要求 continue; end tempBER = errorCount/testCount % 誤碼率 if (tempBER > 0) thresholdTestLongth = 1/tempBER; % 根據(jù)誤碼率來確定測試的長度 else thresholdTestLongth = maxtestlongth; end if (testCount >= thresholdTestLongth) myTestLengt

11、h(index) = testCount; myBER(index) = tempBER; mySNR(index) = SNR; index = index + 1; break end end% endsubplot(222),plot(FSK);title ('FSK信號');subplot(223),plot(noise_FSK);title ('加入噪聲的FSK信號');subplot(224),stairs(DemoFSK(1:20),axis(0,20,-0.2,1.2);title('解調(diào)后的信號');figure(2);subp

12、lot(221),plot(0:length(bitstorm)-1),10*log10(abs(fft(bitstorm);title('調(diào)制信號頻譜');subplot(222),plot(0:length(FSK)-1),10*log10(abs(fft(FSK);title('FSK信號頻譜');subplot(223),plot(0:length(noise_FSK)-1),10*log10(abs(fft(noise_FSK);title('加入噪聲的FSK信號頻譜');subplot(224),plot(0:length(DemoFSK)-1),10*log10(abs(fft(DemoFSK);title('解調(diào)后的信號頻譜');figure(3)semilogy(mySNR,myBER,'r+

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論