write.asv
上传用户:m_sun_001
上传日期:2014-07-30
资源大小:1115k
文件大小:2k
- % write
- % ******************TEST OUTPUT*********************************
- if input_type == 1
- if test_input_type == 1
- %already binary - do nothing
- end
-
- if (test_input_type == 2) | (test_input_type == 3)
- %random input OR sine wave samples
- output_samples = zeros(1,floor(length(output)/8)); %extra zeros are not original data
- for i = 1:length(output_samples)
- output_samples(i) = bin2eight(output(1 + (i-1)*8:(i-1)*8 + 8));
- end
- if do_QAM == 1
- QAM_output_samples = zeros(1,floor(length(QAM_data_out)/8));
- for i = 1:length(QAM_output_samples)
- QAM_output_samples(i) = bin2eight(QAM_data_out(1 + (i-1)*8:(i-1)*8 + 8));
- end
- end
- end
- end
- % ******************FILE OUTPUT*********************************
- if input_type == 2
- if file_input_type == 1
- %binary file output - not implemented
- end
- if file_input_type == 2
- %text file output
- output_samples = zeros(1,floor(length(output)/8)); %extra zeros are not original data
- for i = 1:length(output_samples)
- output_samples(i) = bin2eight(output(1 + (i-1)*8:(i-1)*8 + 8));
- end
- file = fopen('OFDM_text_out.txt','wt+');
- fwrite(file,output_samples,'char');
- fclose(file);
- if do_QAM == 1
- QAM_output_samples = zeros(1,floor(length(QAM_data_out)/8)); %extra zeros are not original data
- for i = 1:length(QAM_output_samples)
- QAM_output_samples(i) = bin2eight(QAM_data_out(1 + (i-1)*8:(i-1)*8 + 8));
- end
- file = fopen('QAM_text_out.txt','wt+');
- fwrite(file,QAM_output_samples,'char');
- fclose(file);
- end
- end
- if file_input_type == 3
- output_samples_big = zeros(1,floor(length(output)/8)); %extra zeros are not original data
- for i = 1:length(output_samples_big)
- output_samples_big(i) = bin2eight(output(1 + (i-1)*8:(i-1)*8 + 8));
- end
- %convert dynamic range from 0:255 to -1:1
- output_samples = (output_samples_big-127)/128;
- %sound file output
- wavwrite(output_samples, 11025, 8, 'OFDM_out.wav')
- if do_QAM == 1
- QAM_data_out_big = zeros(1,floor(length(QAM_data_out)/8));
- for i = 1:length(QAM_data_out_big)
- QAM_data_out_big(i) = bin2eight(QAM_data_out(1 + (i-1)*8:(i-1)*8 + 8));
- end
- %convert dynamic range from 0:255 to -1:1
- QAM_output_samples = (QAM_data_out_big-127)/128;
- %sound file output
- wavwrite(QAM_output_samples, 11025, 8, 'QAM_out.wav')
- end
- end
-
- if file_input_type == 4
- %image file output - not implemented
- end
- end