function [y,t,theta] = OFDM(signalPresent,SNR,fs,theta) % DVBT() generates four OFDM signals over a single symbol period of 1.25 ms (cyclic frequency % included). The OFDM signals have baseband carriers between 592 kHz and 7408 kHz inclusive % in increments of 1 kHz. Carrier frequencies of the signals range from 48 MHz to 96 MHz % in increments of 16 MHz. % Inputs: % SNR: desired SNR (in dB) % fs: sampling frequency (in Hz) % theta: phase of cosine modulator (in radians) % signalPresent: if signalPresent is 0, QPSK symbols are 0; otherwise, QPSK symbols are randomized % Outputs: % y: the resultant OFDM signal with AWGN noise producing the desired SNR % t: times corresponding to the signal % theta: the phase of the cosine modulator if(nargin() <= 3) theta = unifrnd(0,2*pi,1); end if(nargin() <= 2) fs = 500*10^6; end if (nargin() <= 1) SNR = 0; end if (nargin() == 0) signalPresent = 1; end n = 4; % number of OFDM signals nss = 6817; % number of symbols per signal per symbol time fsc = 10^3; % frequency separation of subcarriers fc = 60*10^6; % OFDM signal carrier frequency fbb = (592:592+nss-1)*fsc; % subcarrier frequencies at baseband fbw = 8*10^6; % nominal bandwidth cp = 0.25; % cyclic prefix % generate random QPSK symbols symbols = (2*binornd(1,.5,[nss,1])-1 + 1i*(2*binornd(1,.5,[nss,1])-1))/sqrt(2); % define the DFT of the four signals S_baseband = [zeros(fbb(1)/fsc,1);symbols;zeros(fs/fsc-fbb(1)/fsc-length(symbols),1)]*fs/fsc; % move the baseband signals into the time domain s_baseband = ifft(S_baseband); % modulate the baseband signal t = (0:1/fs:1/fsc-1/fs)'; s = cos(2*pi*fc*t+theta).*s_baseband; % add a cyclic prefix s = [s((length(s)*3/4+1):length(s));s]; % update t in consideration of cyclic prefix t = [t;max(t)+t(1:length(t)/4)]; % apply noise to the received signal y = awgn(s,SNR,'measured'); % if signal isn't supposed to be present, keep the noise if(signalPresent==0) y = y-s; end endfunction