setup.asv
上传用户:m_sun_001
上传日期:2014-07-30
资源大小:1115k
文件大小:3k
- % setup
- disp(' '), disp('------------------------------------------------------------')
- disp('Simulation Setup')
- % OFDM Setup -----------------------------------------------------------
- fft_size = 128 % should be a power of 2 for fast computation
- % more points = more time domain samples (smoother & more cycles)
- num_carriers = 32 % should be <= fft_size/4
- % number of carriers used for each data chunk
- % new var - denotes even spacing or variations of carriers among fft points
- input_type = 2;
- % 1 = test input
- test_input_type = 1;
- % 1 = bit specified (binary)
- binary_data = [0 1 0 1 0 1 0 1];
- % 2 = random data stream (samples in the range of 0-255)
- num_symbols = 9;
- % 3 = sinusoidal
- frequency = 2;
- num_samples = 50;
- % 2 = external file input
- file_name = 'shortest.wav'; % Name of input file
- file_input_type = 3;
- % 1 = binary (not implemented)
- % 2 = text % Demo file: 'text.txt'
- % 3 = sound % Demo files: 'shortest.wav' & 'shorter.wav'
- % 4 = image (not implemented)
- % QAM Setup ------------------------------------------------------------
- do_QAM = 1; % (1=on, 0=off)
- QAM_periods = 10; % defines the number of periods per QAM Symbos (1=2*pi)
- % Channel Simulation Parameters --------------------------------------------
- channel_on = 1; % 1=on, 0=off
- clip_level = 1.0; % 0.0 - 1.0 (0-100%)
- % Max magnitude of the signal is 'clip_level' times the full magnitude of the signal
- noise_level = 0.0; % 0.0 - 1.0 (0-100%)
- % Magnitude of noise is 'noise_level' times the magnitude of the signal
- % Multipath Channel Simulation
- % Good defaults when fft_size = 128 and num_carriers = 32:
- % d1=6; a1=0.30; d2=10; a2=0.25
- d1 = 6; % delay in units
- a1 = 0.30; % attenuation factor - multipath signal is x% of size or original signal
- d2 = 10; % delay for second multipath signal
- a2 = 0.25; % attenuation factor for second multipath signal
- % ****************** TEST INPUT SETUP - DO NOT MODIFY **************************
- if input_type == 1
- if test_input_type == 1
- %specify BINARY input bit-by-bit
- data_in = binary_data;
- end
- if test_input_type == 2
- %random input defined by parameters
- num_levels = 255; %number of possible levels of a symbol
- %must be integer between 1-255
- data_samples = round(rand(1,num_symbols)*(num_levels-1));
- data_in = zeros(1,8*length(data_samples));
- for i = 1:length(data_samples)
- data_in(1 + (i-1)*8:(i-1)*8 + 8) = eight2bin(data_samples(i));
- end
- end
- if test_input_type == 3
- %data stream represents sine wave samples
- t = linspace(0,1,num_symbols); %evenly space number of samples
- %take 8-bit samples of sine wave
- data_samples = round(127.5*sin(frequency*2*pi*t) +127.5);
- data_in = zeros(1,8*length(data_samples));
- for i = 1:length(data_samples)
- data_in(1 + (i-1)*8:(i-1)*8 + 8) = eight2bin(data_samples(i));
- end
- end
- end
- already_made_noise = 0; % initialization (don't change)