資源簡介
ofdm的簡單仿真matlab程序,里面畫出了9格圖可以更好的理解ofdm
代碼片段和文件信息
%--------1---------2---------3---------4---------5---------6---------7---------8
%?OFDM?Simulation
clear?all;
close?all;
%?Basic?OFDM?system?parameters
fprintf?(‘OFDM?Analysis?Program\n\n‘);
defaults?=?input(‘To?use?default?parameters?input?“1“?otherwise?input?“0“:??‘);
if?defaults?==?1
????IFFT_bin_length?=?1024;?????%?IFFT?bin?count?for?Tx?FFT?bin?count?for?Rx
????carrier_count?=?200;????????%?number?of?carriers
????bits_per_symbol?=?2;????????%?bits?per?symbol??00011011
????symbols_per_carrier?=?50;???%?symbols?per?carrier
????SNR?=?10;???????????????????%?channel?signal?to?noise?ratio?(dB)???????????????????????????
else
????IFFT_bin_length?=?input(‘IFFT?bin?length?=?‘);
????carrier_count?=?input(‘carrier?count?=?‘);
????bits_per_symbol?=?input(‘bits?per?symbol?=?‘);
????symbols_per_carrier?=?input(‘symbols?per?carrier?=‘);
????SNR?=?input(‘SNR?=?‘);
end
%?Derived?parameters
baseband_out_length?=??carrier_count?*?symbols_per_carrier?*?bits_per_symbol;?%?20000
carriers?=?(1:carrier_count)?+?(floor(IFFT_bin_length/4)?-?floor(carrier_count/2))%?從157-356共200個子載波
conjugate_carriers?=?IFFT_bin_length?-?carriers?+?2;?%?從869-670共200個子載波
%?carriers?和?conjugate_carriers?是關于第513號載波對稱的
%--------1---------2---------3---------4---------5---------6---------7---------8
%?TRANSMIT?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%?Generate?a?random?binary?output?signal:
%???-?a?row?of?uniform?random?numbers?(between?0?and?1)?rounded?to?0?or?1
%???-?this?will?be?the?baseband?signal?which?is?to?be?transmitted.
baseband_out?=?round(rand(1baseband_out_length));?%?20000個隨機數,0、1
%?Convert?to?‘modulo?N‘?integers?where?N?=?2^bits_per_symbol
%???-?this?defines?how?many?states?each?symbol?can?represent
%???-?first?make?a?matrix?with?each?column?representing?consecutive?bits?
%?????from?the?input?stream?and?the?number?of?bits?in?a?column?equal?to?the
%?????number?of?bits?per?symbol
%???-?then?for?each?column?multiply?each?row?value?by?the?power?of?2?that?
%?????it?represents?and?add?all?the?rows
%???-?for?example:??input?0?1?1?0?0?0?1?1?1?0
%???????????????????bits_per_symbol?=?2
%???????????????????convert_matrix?=?0?1?0?1?1
%????????????????????????????????????1?0?0?1?0
%???????????????????modulo_baseband?=?1?2?0?3?2
convert_matrix?=?reshape(baseband_out?bits_per_symbol?length(baseband_out)/bits_per_symbol);?%?變成了一個2行10000列的矩陣
for?k?=?1:(length(baseband_out)/bits_per_symbol)?%?k=1:10000
????modulo_baseband(k)?=?0;
????for?i?=?1:bits_per_symbol?%?i=1:2
????????modulo_baseband(k)?=?modulo_baseband(k)?+?convert_matrix(ik)*2^(bits_per_symbol-i);
????end
end
%?modulo_baseband?是一個1行10000列的向量,每個元素可能為[0,1,2,3]
%--------1---------2---------3---------4---------5---------6---------7---------8
%?Serial?to?Parallel?Conversion
%???-?convert?the?serial?modulo?N?stream?into?a?matrix?where?each?column?
%?????represents?a?carrier?and?each?row?represents?a?symbol
%???-?for?example:
%
- 上一篇:mATlab自編理想低通濾波器
- 下一篇:matlab仿真中的T2F函數
評論
共有 條評論