tx_chunk.m
上传用户:m_sun_001
上传日期:2014-07-30
资源大小:1115k
文件大小:2k
- % tx_chunk
- data_length = length(data_in_pol) %number of symbols in original input
- num_carriers
- num_chunks = ceil(data_length/(2*num_carriers)) %2 data on each carrier (real and imaginary)
- r = rem(data_length,2*num_carriers) %remainer of
- if r ~= 0
- for i = 1:num_carriers*2-r
- data_in_pol(data_length+i) = 0; %pad input with zeros to complete last data set
- end %speed improve possible
- end
- % break data into chunks
- chunks = zeros(num_chunks,num_carriers); % for speed
- for i = 1:num_chunks
- % *********************chunk done
- for k = 1:num_carriers
- chunks(i,k) = data_in_pol(2*num_carriers*(i-1)+k) + data_in_pol(2*num_carriers*(i-1)+k+num_carriers)*j;
- end
- end
- chunks;%2005_05_23----------------------------------------------------
- % Padding chunks with zeros so num_carriers and fft_size are compatible
- % Once compatible, further spacing is simplified
- num_desired_carriers = num_carriers;
- num_zeros = 0;
- thinking = 1;
- fft_size
- while thinking == 1 % Continue if num_carriers and fft_size are not compatible
- if rem(fft_size/2,num_desired_carriers) == 0
- thinking = 0;
- else
- num_desired_carriers = num_desired_carriers + 1;
- num_zeros = num_zeros + 1;
- end
- end
- padded_chunks = zeros(num_chunks,num_carriers + num_zeros);% for speed
- padded_chunks(1:num_chunks,num_zeros + 1:num_carriers + num_zeros) = chunks;
- %compute zeros_between
- zeros_between = ((fft_size/2) - (num_carriers + num_zeros))/(num_carriers + num_zeros);
- spaced_chunks = zeros(num_chunks,fft_size); % for speed - extra room for folding later
- %add zeros_between
- i = 1;
- for k = zeros_between +1:zeros_between +1:fft_size/2
- spaced_chunks(1:num_chunks,k) = padded_chunks(1:num_chunks,i);
- i = i+1;
- end
- % folding data to produce an odd function for ifft input
- for i = 1:num_chunks
- % Note: index = 1 is actually DC freq for ifft -> it does not get copied over y-axis
- spaced_chunks(i,fft_size:-1:fft_size/2+2) = conj(spaced_chunks(i,2:fft_size/2));
- end
- spaced_chunks;