├── .gitattributes ├── Clake and Jakes channel ├── Clarke Model and Jakes model analysis.docx ├── Clarke │ ├── Clarke.m │ ├── Clarke_model.m │ └── Doppler.m └── Jakes │ ├── Jakes.asv │ ├── Jakes.m │ └── Jakes_model.m ├── MIMO-OFDM-Wireless-Communications-with-MATLAB ├── Alamouti_2x1_ant_selection.m ├── Alamouti_2x1_precoding.m ├── Alamouti_scheme.m ├── Block_diagonalization.m ├── CCDF_OFDMA.m ├── CCDF_PAPR_DFTspreading.m ├── CCDF_PTS.m ├── CCDF_of_clipped_filtered_OFDM_signal.m ├── CFO_CP.m ├── CFO_Classen.m ├── CFO_Moose.m ├── CFO_estimation.m ├── Dirty_or_TH_precoding.m ├── Doppler_PSD_function.m ├── Doppler_spectrum.m ├── Ergodic_Capacity_CDF.m ├── Ergodic_Capacity_Correlation.m ├── Ergodic_Capacity_vs_SNR.m ├── FWGN.m ├── FWGN_ff.m ├── FWGN_model.m ├── FWGN_tf.m ├── IEEE802_11_model.m ├── IFFT_oversampling.m ├── Jakes_Flat.m ├── LRAD_MMSE.m ├── LS_CE.m ├── MIMO_OFDM_program_list.pdf ├── MIMO_channel_cap_ant_sel_optimal.m ├── MIMO_channel_cap_ant_sel_subopt.m ├── MMSE_CE.m ├── MMSE_detection_2x2.m ├── MRC_scheme.m ├── OFDM_BER_AWGN_CP_GL16.dat ├── OFDM_basic.m ├── OFDM_signal.m ├── OL_CL_Comparison.m ├── OSIC_detector.m ├── PAPR.m ├── PAPR_of_Chu.m ├── PAPR_of_preamble.m ├── PARR_of_preamble.m ├── PDF_of_clipped_and_filtered_OFDM_signal.m ├── PL_Hata.m ├── PL_IEEE80216d.m ├── PL_free.m ├── PL_logdist_or_norm.m ├── Q.m ├── QAM16_demapper.m ├── QAM16_mod.m ├── QAM16_slicer.m ├── QAM16_slicer_soft.m ├── QPSK_mapper.m ├── QRM_MLD_detector.m ├── QRM_MLD_simulation.m ├── QRM_MLD_soft.m ├── Ray_model.m ├── Ric_model.m ├── SD_detector.m ├── SQNR_with_quantization_clipping.m ├── SQRD_.m ├── STBC_3x4_simulation.m ├── STO_by_correlation.m ├── STO_by_difference.m ├── STO_estimation.m ├── STTC_detector.m ├── STTC_modulator.m ├── STTC_simulation.m ├── STTC_stage_modulation.m ├── SUI_fading.m ├── SUI_parameters.m ├── SV_model_ct.m ├── UWB_convert_ct.m ├── UWB_model_ct.m ├── UWB_parameters.m ├── Viterbi_init.m ├── Water_Pouring.m ├── Wibro-Preamble │ ├── C80216e-04_241r1_pdf.dat │ ├── Preamble_sym0.dat │ ├── Preamble_sym1.dat │ ├── Preamble_sym10.dat │ ├── Preamble_sym100.dat │ ├── Preamble_sym101.dat │ ├── Preamble_sym102.dat │ ├── Preamble_sym103.dat │ ├── Preamble_sym104.dat │ ├── Preamble_sym105.dat │ ├── Preamble_sym106.dat │ ├── Preamble_sym107.dat │ ├── Preamble_sym108.dat │ ├── Preamble_sym109.dat │ ├── Preamble_sym11.dat │ ├── Preamble_sym110.dat │ ├── Preamble_sym111.dat │ ├── Preamble_sym112.dat │ ├── Preamble_sym113.dat │ ├── Preamble_sym12.dat │ ├── Preamble_sym13.dat │ ├── Preamble_sym14.dat │ ├── Preamble_sym15.dat │ ├── Preamble_sym16.dat │ ├── Preamble_sym17.dat │ ├── Preamble_sym18.dat │ ├── Preamble_sym19.dat │ ├── Preamble_sym2.dat │ ├── Preamble_sym20.dat │ ├── Preamble_sym21.dat │ ├── Preamble_sym22.dat │ ├── Preamble_sym23.dat │ ├── Preamble_sym24.dat │ ├── Preamble_sym25.dat │ ├── Preamble_sym26.dat │ ├── Preamble_sym27.dat │ ├── Preamble_sym28.dat │ ├── Preamble_sym29.dat │ ├── Preamble_sym3.dat │ ├── Preamble_sym30.dat │ ├── Preamble_sym31.dat │ ├── Preamble_sym32.dat │ ├── Preamble_sym33.dat │ ├── Preamble_sym34.dat │ ├── Preamble_sym35.dat │ ├── Preamble_sym36.dat │ ├── Preamble_sym37.dat │ ├── Preamble_sym38.dat │ ├── Preamble_sym39.dat │ ├── Preamble_sym4.dat │ ├── Preamble_sym40.dat │ ├── Preamble_sym41.dat │ ├── Preamble_sym42.dat │ ├── Preamble_sym43.dat │ ├── Preamble_sym44.dat │ ├── Preamble_sym45.dat │ ├── Preamble_sym46.dat │ ├── Preamble_sym47.dat │ ├── Preamble_sym48.dat │ ├── Preamble_sym49.dat │ ├── Preamble_sym5.dat │ ├── Preamble_sym50.dat │ ├── Preamble_sym51.dat │ ├── Preamble_sym52.dat │ ├── Preamble_sym53.dat │ ├── Preamble_sym54.dat │ ├── Preamble_sym55.dat │ ├── Preamble_sym56.dat │ ├── Preamble_sym57.dat │ ├── Preamble_sym58.dat │ ├── Preamble_sym59.dat │ ├── Preamble_sym6.dat │ ├── Preamble_sym60.dat │ ├── Preamble_sym61.dat │ ├── Preamble_sym62.dat │ ├── Preamble_sym63.dat │ ├── Preamble_sym64.dat │ ├── Preamble_sym65.dat │ ├── Preamble_sym66.dat │ ├── Preamble_sym67.dat │ ├── Preamble_sym68.dat │ ├── Preamble_sym69.dat │ ├── Preamble_sym7.dat │ ├── Preamble_sym70.dat │ ├── Preamble_sym71.dat │ ├── Preamble_sym72.dat │ ├── Preamble_sym73.dat │ ├── Preamble_sym74.dat │ ├── Preamble_sym75.dat │ ├── Preamble_sym76.dat │ ├── Preamble_sym77.dat │ ├── Preamble_sym78.dat │ ├── Preamble_sym79.dat │ ├── Preamble_sym8.dat │ ├── Preamble_sym80.dat │ ├── Preamble_sym81.dat │ ├── Preamble_sym82.dat │ ├── Preamble_sym83.dat │ ├── Preamble_sym84.dat │ ├── Preamble_sym85.dat │ ├── Preamble_sym86.dat │ ├── Preamble_sym87.dat │ ├── Preamble_sym88.dat │ ├── Preamble_sym89.dat │ ├── Preamble_sym9.dat │ ├── Preamble_sym90.dat │ ├── Preamble_sym91.dat │ ├── Preamble_sym92.dat │ ├── Preamble_sym93.dat │ ├── Preamble_sym94.dat │ ├── Preamble_sym95.dat │ ├── Preamble_sym96.dat │ ├── Preamble_sym97.dat │ ├── Preamble_sym98.dat │ └── Preamble_sym99.dat ├── add_CFO.m ├── add_CP.m ├── add_STO.m ├── add_pilot.m ├── assign_offset.m ├── ber_QAM.m ├── bound.m ├── calculate_norm.m ├── channel1.m ├── channel_coeff.m ├── channel_estimation.m ├── clipping.m ├── codebook_generator.m ├── compare_CCDF_PTS.m ├── compare_DFT_spreading.m ├── compare_DFT_spreading_w_psf.m ├── compare_vector_norm.m ├── convert_UWB_ct.m ├── dB2w.m ├── data_generator.m ├── do_STO_CFO1.m ├── equalpower_subray.m ├── exp_pdp.m ├── gen_filter.m ├── gen_phase.m ├── guard_interval.m ├── interpolate.m ├── license.txt ├── list_length.m ├── mapper.m ├── modulation.m ├── modulator.m ├── modulo.m ├── multi_user_MIMO.m ├── original_LLL_.m ├── plot_2ray_exp_model.m ├── plot_CCDF.m ├── plot_FWGN.m ├── plot_IEEE80211_model.m ├── plot_Jakes_model.m ├── plot_PL_Hata.m ├── plot_PL_IEEE80216d.m ├── plot_PL_general.m ├── plot_Ray_Ric_channel.m ├── plot_SUI_channel.m ├── plot_SV_model_ct.m ├── plot_UWB_channel.m ├── plot_ber.m ├── plot_modified_FWGN.m ├── plot_ray_fading.m ├── pre_MMSE.m ├── radius_control.m ├── ray_fading.m ├── readme.txt ├── remove_CP.m ├── remove_GI.m ├── single_carrier_PAPR.m ├── soft_decision_sigma.m ├── soft_hard_SISO.m ├── soft_output2x2.m ├── sort_matrix.m ├── stage_processing.m ├── stage_processing1.m ├── test_orthogonality.m ├── trellis_encoder.m ├── vector_comparison.m ├── zero_insertion.m └── zero_padding.m ├── README.md ├── key generation in backscatter communication ├── SNR10.mat ├── SNR8_RSS_scheme1.mat ├── backscatter_rayleigh_v3.m ├── backscatter_rayleign.m ├── backscatter_rayleign_v2.m ├── key-generation-between-pt-tag.eps ├── power_pt_arrat_v1.mat ├── rayleigh_test.m ├── scheme1-Eve-final.mat ├── scheme1-Eve-final_v1.mat ├── scheme1-Eve-v1.mat ├── scheme1_Eve_v1.m ├── scheme1_v1.m ├── scheme1_v2.m ├── scheme1_v2.mat ├── scheme2-Eve-final.mat ├── scheme2_test.m ├── scheme2_test2.m ├── scheme2_v1.m ├── scheme_test2_array_314.mat └── scheme_test2_array_v1.mat ├── rake receiver ├── mgen.m ├── rake_3path_max.m └── sigexpand.m └── rayleigh channel simulation ├── AM.m ├── FSK.m ├── SNR10.mat ├── SNR8_RSS_scheme1.mat ├── c1D_tf_801.m ├── multi_fading_channel.m ├── multi_fading_channel_wp.m ├── multi_sin_power.m ├── multipath_path_channel.slx ├── ofdm_fading.m ├── power_pt_arrat_v1.mat ├── qam_16.m ├── ray_exp.m ├── ray_jakes.m ├── rayleigh.m ├── rayleighchann_simulation.m ├── scheme2_test.m ├── scheme2_test2.m ├── scheme2_v1.m ├── scheme_test2_array_v1.mat ├── single_sin_power.m ├── spectrum_analysisr.m ├── test_bessel.m ├── test_function.m ├── test_power.m ├── test_rayleighchan.m ├── test_signal.m ├── test_signal_FFT.m ├── test_signal_FFT2.m ├── test_signal_FFT_phase.m ├── test_signal_power.m └── untitled.slx /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Clake and Jakes channel/Clarke Model and Jakes model analysis.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Clarke Model and Jakes model analysis.docx -------------------------------------------------------------------------------- /Clake and Jakes channel/Clarke/Clarke.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Clarke/Clarke.m -------------------------------------------------------------------------------- /Clake and Jakes channel/Clarke/Clarke_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Clarke/Clarke_model.m -------------------------------------------------------------------------------- /Clake and Jakes channel/Clarke/Doppler.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Clarke/Doppler.m -------------------------------------------------------------------------------- /Clake and Jakes channel/Jakes/Jakes.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Jakes/Jakes.asv -------------------------------------------------------------------------------- /Clake and Jakes channel/Jakes/Jakes.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Jakes/Jakes.m -------------------------------------------------------------------------------- /Clake and Jakes channel/Jakes/Jakes_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/Clake and Jakes channel/Jakes/Jakes_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_2x1_ant_selection.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_2x1_ant_selection.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_2x1_precoding.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_2x1_precoding.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_scheme.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Alamouti_scheme.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Block_diagonalization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Block_diagonalization.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_OFDMA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_OFDMA.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_PAPR_DFTspreading.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_PAPR_DFTspreading.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_PTS.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_PTS.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_of_clipped_filtered_OFDM_signal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CCDF_of_clipped_filtered_OFDM_signal.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_CP.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_CP.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_Classen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_Classen.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_Moose.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_Moose.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_estimation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/CFO_estimation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Dirty_or_TH_precoding.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Dirty_or_TH_precoding.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Doppler_PSD_function.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Doppler_PSD_function.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Doppler_spectrum.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Doppler_spectrum.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_CDF.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_CDF.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_Correlation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_Correlation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_vs_SNR.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Ergodic_Capacity_vs_SNR.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_ff.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_ff.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_tf.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/FWGN_tf.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/IEEE802_11_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/IEEE802_11_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/IFFT_oversampling.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/IFFT_oversampling.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Jakes_Flat.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Jakes_Flat.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/LRAD_MMSE.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/LRAD_MMSE.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/LS_CE.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/LS_CE.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_OFDM_program_list.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_OFDM_program_list.pdf -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_channel_cap_ant_sel_optimal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_channel_cap_ant_sel_optimal.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_channel_cap_ant_sel_subopt.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MIMO_channel_cap_ant_sel_subopt.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MMSE_CE.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MMSE_CE.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MMSE_detection_2x2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MMSE_detection_2x2.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/MRC_scheme.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/MRC_scheme.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/OFDM_BER_AWGN_CP_GL16.dat: -------------------------------------------------------------------------------- 1 | %Signal power= 1.172e-002 2 | %EbN0[dB] BER 3 | 0 1.432e-001 4 | 5 4.688e-002 5 | 10 1.946e-003 6 | -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/OFDM_basic.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/OFDM_basic.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/OFDM_signal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/OFDM_signal.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/OL_CL_Comparison.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/OL_CL_Comparison.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/OSIC_detector.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/OSIC_detector.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR_of_Chu.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR_of_Chu.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR_of_preamble.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PAPR_of_preamble.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PARR_of_preamble.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PARR_of_preamble.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PDF_of_clipped_and_filtered_OFDM_signal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PDF_of_clipped_and_filtered_OFDM_signal.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_Hata.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_Hata.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_IEEE80216d.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_IEEE80216d.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_free.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_free.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_logdist_or_norm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/PL_logdist_or_norm.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Q.m: -------------------------------------------------------------------------------- 1 | function y=Q(x) 2 | % co-error function: 1/sqrt(2*pi) * int_x^inf exp(-t^2/2) dt. 3 | y=erfc(x/sqrt(2))/2; -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_demapper.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_demapper.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_mod.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_mod.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_slicer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_slicer.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_slicer_soft.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QAM16_slicer_soft.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QPSK_mapper.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QPSK_mapper.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_detector.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_detector.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_simulation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_simulation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_soft.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/QRM_MLD_soft.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Ray_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Ray_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Ric_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Ric_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SD_detector.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SD_detector.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SQNR_with_quantization_clipping.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SQNR_with_quantization_clipping.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SQRD_.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SQRD_.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STBC_3x4_simulation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STBC_3x4_simulation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_by_correlation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_by_correlation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_by_difference.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_by_difference.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_estimation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STO_estimation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_detector.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_detector.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_modulator.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_modulator.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_simulation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_simulation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_stage_modulation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/STTC_stage_modulation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SUI_fading.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SUI_fading.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SUI_parameters.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SUI_parameters.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/SV_model_ct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/SV_model_ct.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_convert_ct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_convert_ct.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_model_ct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_model_ct.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_parameters.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/UWB_parameters.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Viterbi_init.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Viterbi_init.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Water_Pouring.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/Water_Pouring.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/Wibro-Preamble/C80216e-04_241r1_pdf.dat: -------------------------------------------------------------------------------- 1 | %Index IDcell Segment Sequence-Index PAPR PAPR(C802.16e-01-125) 2 | 0 0 0 147 2.58 3.65 3 | 1 1 0 146 2.58 4.09 4 | 2 2 0 292 2.64 3.93 5 | 3 3 0 1 2.64 3.94 6 | 4 4 0 117 2.78 4.14 7 | 5 5 0 176 2.78 4.13 8 | 6 6 0 220 2.9 4 9 | 7 7 0 73 2.9 4.01 10 | 8 8 0 49 2.95 4.1 11 | 9 9 0 244 2.95 4.02 12 | 10 10 0 98 3.11 4.05 13 | 11 11 0 195 3.11 3.98 14 | 12 12 0 42 3.12 4.05 15 | 13 13 0 251 3.12 4.14 16 | 14 14 0 205 3.17 4.08 17 | 15 15 0 88 3.17 4.2 18 | 16 16 0 45 3.19 4 19 | 17 17 0 248 3.19 4.2 20 | 18 18 0 185 3.2 4.15 21 | 19 19 0 108 3.2 4.26 22 | 20 20 0 224 3.22 4.25 23 | 21 21 0 69 3.22 4.11 24 | 22 22 0 179 3.25 4.17 25 | 23 23 0 114 3.25 3.96 26 | 24 24 0 21 3.26 4.12 27 | 25 25 0 272 3.26 4.27 28 | 26 26 0 228 3.27 4.26 29 | 27 27 0 65 3.27 4.04 30 | 28 28 0 149 3.33 4.25 31 | 29 29 0 144 3.33 4.14 32 | 30 30 0 39 3.33 4.2 33 | 31 31 0 254 3.33 4.26 34 | 32 0 1 292 2.31 3.96 35 | 33 1 1 1 2.31 3.96 36 | 34 2 1 146 2.41 3.97 37 | 35 3 1 147 2.41 3.97 38 | 36 4 1 73 2.63 3.97 39 | 37 5 1 220 2.63 3.98 40 | 38 6 1 49 2.71 3.98 41 | 39 7 1 244 2.71 3.99 42 | 40 8 1 42 2.77 3.99 43 | 41 9 1 251 2.77 3.99 44 | 42 10 1 117 2.77 3.99 45 | 43 11 1 176 2.77 3.99 46 | 44 12 1 98 2.83 3.99 47 | 45 13 1 195 2.83 4 48 | 46 14 1 179 2.88 4 49 | 47 15 1 114 2.88 4 50 | 48 16 1 185 2.99 4 51 | 49 17 1 108 2.99 4.01 52 | 50 18 1 248 3 4.01 53 | 51 19 1 45 3 4.01 54 | 52 20 1 224 3 4.02 55 | 53 21 1 69 3 4.02 56 | 54 22 1 40 3.03 4.02 57 | 55 23 1 253 3.03 4.02 58 | 56 24 1 272 3.04 4.02 59 | 57 25 1 21 3.04 4.02 60 | 58 26 1 39 3.05 4.02 61 | 59 27 1 254 3.05 4.02 62 | 60 28 1 238 3.06 4.03 63 | 61 29 1 55 3.06 4.03 64 | 62 30 1 110 3.14 4.03 65 | 63 31 1 183 3.14 4.03 66 | 64 0 2 292 2.28 4.27 67 | 65 1 2 1 2.28 4.36 68 | 66 2 2 73 2.51 4.35 69 | 67 3 2 220 2.51 4.29 70 | 68 4 2 98 2.58 4.37 71 | 69 5 2 195 2.58 4.2 72 | 70 6 2 146 2.63 4.35 73 | 71 7 2 147 2.63 4.37 74 | 72 8 2 42 2.84 4.21 75 | 73 9 2 251 2.84 4.12 76 | 74 10 2 244 2.85 4.11 77 | 75 11 2 49 2.85 4.23 78 | 76 12 2 183 2.86 4.06 79 | 77 13 2 110 2.86 4.19 80 | 78 14 2 117 2.94 4.12 81 | 79 15 2 176 2.94 4.18 82 | 80 16 2 39 2.98 4.22 83 | 81 17 2 254 2.98 4.15 84 | 82 18 2 21 3.03 4.19 85 | 83 19 2 272 3.03 4.17 86 | 84 20 2 253 3.06 4.14 87 | 85 21 2 40 3.06 4.24 88 | 86 22 2 179 3.06 4.21 89 | 87 23 2 114 3.06 4.29 90 | 88 24 2 69 3.07 4.27 91 | 89 25 2 224 3.07 4.31 92 | 90 26 2 228 3.12 4.25 93 | 91 27 2 65 3.12 4.29 94 | 92 28 2 157 3.2 4.13 95 | 93 29 2 136 3.2 4.23 96 | 94 30 2 51 3.21 4.15 97 | 95 31 2 242 3.21 4.15 98 | 96 0 0 83 3.34 4.26 99 | 97 1 1 171 3.17 4.03 100 | 98 2 2 55 3.22 4.2 101 | 99 3 0 210 3.34 4.1 102 | 100 4 1 122 3.17 4.04 103 | 101 5 2 238 3.22 4.25 104 | 102 6 0 122 3.35 4.22 105 | 103 7 1 65 3.18 4.05 106 | 104 8 2 82 3.23 4.2 107 | 105 9 0 171 3.35 4.28 108 | 106 10 1 228 3.18 4.05 109 | 107 11 2 211 3.23 4.35 110 | 108 12 0 238 3.35 4.37 111 | 109 13 1 205 3.22 4.06 112 | 110 14 2 83 3.26 4.35 113 | 111 15 0 55 3.35 4.13 114 | 112 16 1 88 3.22 4.06 115 | 113 17 2 210 3.26 4.23 -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/add_CFO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/add_CFO.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/add_CP.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/add_CP.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/add_STO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/add_STO.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/add_pilot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/add_pilot.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/assign_offset.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/assign_offset.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/ber_QAM.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/ber_QAM.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/bound.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/bound.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/calculate_norm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/calculate_norm.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/channel1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/channel1.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/channel_coeff.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/channel_coeff.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/channel_estimation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/channel_estimation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/clipping.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/clipping.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/codebook_generator.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/codebook_generator.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_CCDF_PTS.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_CCDF_PTS.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_DFT_spreading.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_DFT_spreading.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_DFT_spreading_w_psf.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_DFT_spreading_w_psf.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_vector_norm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/compare_vector_norm.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/convert_UWB_ct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/convert_UWB_ct.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/dB2w.m: -------------------------------------------------------------------------------- 1 | function y=dB2w(dB) 2 | y=10.^(0.1*dB); -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/data_generator.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/data_generator.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/do_STO_CFO1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/do_STO_CFO1.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/equalpower_subray.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/equalpower_subray.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/exp_pdp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/exp_pdp.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/gen_filter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/gen_filter.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/gen_phase.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/gen_phase.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/guard_interval.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/guard_interval.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/interpolate.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/interpolate.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/license.txt -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/list_length.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/list_length.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/mapper.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/mapper.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/modulation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/modulation.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/modulator.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/modulator.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/modulo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/modulo.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/multi_user_MIMO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/multi_user_MIMO.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/original_LLL_.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/original_LLL_.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_2ray_exp_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_2ray_exp_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_CCDF.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_CCDF.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_FWGN.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_FWGN.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_IEEE80211_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_IEEE80211_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_Jakes_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_Jakes_model.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_Hata.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_Hata.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_IEEE80216d.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_IEEE80216d.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_general.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_PL_general.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_Ray_Ric_channel.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_Ray_Ric_channel.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_SUI_channel.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_SUI_channel.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_SV_model_ct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_SV_model_ct.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_UWB_channel.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_UWB_channel.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_ber.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_ber.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_modified_FWGN.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_modified_FWGN.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_ray_fading.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/plot_ray_fading.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/pre_MMSE.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/pre_MMSE.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/radius_control.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/radius_control.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/ray_fading.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/ray_fading.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/readme.txt -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/remove_CP.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/remove_CP.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/remove_GI.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/remove_GI.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/single_carrier_PAPR.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/single_carrier_PAPR.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_decision_sigma.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_decision_sigma.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_hard_SISO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_hard_SISO.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_output2x2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/soft_output2x2.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/sort_matrix.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/sort_matrix.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/stage_processing.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/stage_processing.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/stage_processing1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/stage_processing1.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/test_orthogonality.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/test_orthogonality.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/trellis_encoder.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/trellis_encoder.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/vector_comparison.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/vector_comparison.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/zero_insertion.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/zero_insertion.m -------------------------------------------------------------------------------- /MIMO-OFDM-Wireless-Communications-with-MATLAB/zero_padding.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/MIMO-OFDM-Wireless-Communications-with-MATLAB/zero_padding.m -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # wireless-communication 4 | 无线信道matlab仿真等文件 5 | ### Clake and Jakes channel simulation 6 | 7 | ### rake 接收机仿真 8 | * rake 接收机 9 | 10 | ### rayleigh channel simulation 11 | * rayleigh 信号以及jake接收机仿真 12 | * test_signal 信号生成仿真 13 | * test_signal_FFT 信号Fourier变换仿真 14 | * test_power 信号功率谱变换仿真 15 | * single_sin_power 单个频率的正弦信号的功率以及功率谱的计算 16 | * multi_sin_power 多个频率的正弦信号的功率以及功率谱的计算 17 | 18 | ---- 19 | ### 能量信号和功率信号 20 | 21 | 根据信号可以用能量式或者功率式表示可以分为能量信号和功率信号 22 | 23 | #### 能量信号 24 | 如各类瞬变信号,在非电量测量中,常将被测信号转换为电压或者电流信号来处理。电压信号工作在单位电阻\\(R = 1\\)上瞬时功率为\\(P(t) = x^2(t)/R = x^2(t)\\)。瞬时功率对时间的积分即是该时间内的能量。通常不考虑量纲,直接把信号的平方及其时间的积分分别称为信号的功率和能量。当\\(x(t)\\)满足 25 | $$\int_{-\infty}^{+\infty}x^2(t)\,dt < \infty.$$ 26 | 则信号的能量有限,称为能量有限信号,简称能量信号。其满足能量有限条件,实际是满足绝对可积条件。 27 | 我们定义信号\\(f(t)\\)的能量(归一化处理):有电压\\(f(t)\\)或者电流\\(f(t)\\)在1\\(\Omega\\)电阻上消耗的能量: 28 | $$E = \int_{-\infty}^{+\infty}x^2(t)\,dt, (注释:E= u*i=u^2/R=u^2).$$ 29 | 30 | #### 功率信号 31 | 如各种周期信号、常值信号、阶跃信号等,若\\(x(t)\\)在区间\\((-\infty,+\infty)\\)的能量无限,不满足上面的可积条件,但在有限区间\\((-T/2,+T/2)\\)满足平均功率有限的条件 32 | $$\lim_{T \to +\infty} \frac{1}{T} \int_{-T/2}^{T/2} x^2(t)\,dt < +\infty$$ 33 | 我们定义信号\\(f(t)\\)的平均功率,为电压\\(f(t)\\)在1\\(\Omega\\)电阻上消耗的平均功率(简称功率): 34 | $$\lim_{T \to +\infty} \frac{1}{T} \int_{-T/2}^{T/2} x^2(t)\,dt$$ 35 | 36 | 37 | -------------------------------------------------------------------------------- /key generation in backscatter communication/SNR10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/SNR10.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/SNR8_RSS_scheme1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/SNR8_RSS_scheme1.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/backscatter_rayleigh_v3.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************************************* 2 | %% backscatter_rayleigh_v3.m 3 | %% 和版本1一模一样,只不过修改变量名称,在传输过程仿真无噪声环境 4 | %% 测试正弦信号频谱,功率以及功率谱 5 | %% 构造rayleigh衰减信道(如下表格),计算经过信道以及加噪之后信号的功率谱和信号总功率 6 | %% 发射信号,并经过同一rayleigh衰减信道,记忆添加噪声,计算信号的功率谱和总功率 7 | %% @wp 2018-3-7 8 | %%************************************************************************************************* 9 | % backscattering simulation 10 | % Table B.2.1-2 Extended Pedestrian A model (EPA) rayleigh fading channel model 11 | % Excess tap delay[ns/10] Relative power[dB] 12 | % 0 0.0 13 | % 50 -3.0 14 | % 110 -10.0 15 | % 170 -18.0 16 | % 290 -26.0 17 | % 310 -32.0 18 | 19 | 20 | %% 该部分测试正弦信号经过rayleigh衰减信道,和经过rayleigh衰减信道后并添加部分噪声后的 21 | %% 信号功率的比较 22 | 23 | clc; 24 | clear; 25 | close all; 26 | 27 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 28 | N = 10; % 信号周期内的采样点数 29 | Fs = N*f1; % sampling frequency, 采样频率 30 | T = 1/Fs; % sampling period, 采样周期 31 | L = 10000*N; % length of signal 32 | 33 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 34 | A = 4; % 信号幅值 35 | 36 | %% 设置高斯噪声 37 | SNR_tag = 10; 38 | 39 | %% 构造初始信号 40 | source = A*sin(2*pi*f1*t); 41 | 42 | %% 计算初始信号的功率 43 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 44 | power_source = bandpower(Pxx_hamming, F, 'psd'); 45 | power_source_db = 10*log10(power_source/2) 46 | %%************************************************************************************************* 47 | 48 | %% 构造rayleigh信道 49 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 50 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 51 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 52 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 53 | 54 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 55 | rayleigh_chan.ResetBeforeFiltering = 0; 56 | data_after_rayleigh = filter(rayleigh_chan,source); 57 | 58 | %% 计算通过rayleigh信道后的信号功率 59 | [Pxx_hamming_after_rayleigh, F_after_rayleigh]= periodogram(data_after_rayleigh,... 60 | hamming(length(data_after_rayleigh)),[],Fs,'centered', 'psd'); 61 | power_after_rayleigh = bandpower(Pxx_hamming_after_rayleigh,... 62 | F_after_rayleigh, 'psd'); 63 | power_after_rayleigh_db = 10*log10(power_after_rayleigh/2) 64 | 65 | 66 | %% 添加高斯噪声 67 | data_tag = awgn(data_after_rayleigh,SNR_tag,'measured'); 68 | 69 | %% 计算在tag端接收信号的功率 70 | [Pxx_hamming_tag, F_tag] = periodogram(data_tag,hamming(length(data_tag)),[],Fs,'centered','psd'); 71 | power_tag = bandpower(Pxx_hamming_tag,F_tag,'psd'); 72 | power_tag_db = 10*log10(power_tag/2) 73 | %%************************************************************************************************* 74 | 75 | %% 反射路径 76 | %% 发射因子为0.5 77 | coeffi = 1.0; 78 | data_back = data_tag.*coeffi; 79 | 80 | %% 反射后,信号经过再次经过rayleigh信道 81 | rayleigh_chan.ResetBeforeFiltering = 0; 82 | back_after_rayleigh = filter(rayleigh_chan,data_back); 83 | 84 | %% 计算反射之后经过rayleigh信道后的信号功率 85 | [Pxx_hamming_after_back, F_after_back]= periodogram(back_after_rayleigh,... 86 | hamming(length(back_after_rayleigh)),[],Fs,'centered', 'psd'); 87 | power_after_back = bandpower(Pxx_hamming_after_back, F_after_back, 'psd'); 88 | power_after_back_db = 10*log10(power_after_back/2) 89 | 90 | 91 | %% 添加高斯噪声 92 | data_pt = awgn(back_after_rayleigh,SNR_tag,'measured'); 93 | 94 | %% 计算在tag端接收信号的功率 95 | [Pxx_hamming_pt, F_pt] = periodogram(data_pt,hamming(length(data_pt)),[],Fs,'centered','psd'); 96 | power_pt = bandpower(Pxx_hamming_pt,F_pt,'psd'); 97 | power_pt_db = 10*log10(power_pt/2) 98 | %%************************************************************************************************* 99 | 100 | %% 绘制最终PT端接收的信号图形 101 | figure; 102 | plot(t(1:1000),real(data_pt(1:1000))); 103 | % axis([0 inf -1.5 1.5]); 104 | title('sine signal after channel'); 105 | xlabel(['Time(f=',num2str(f1),')']) 106 | ylabel('Amplitude/V'); 107 | 108 | -------------------------------------------------------------------------------- /key generation in backscatter communication/backscatter_rayleign.m: -------------------------------------------------------------------------------- 1 | %% backscatter_rayleign.m 2 | %%************************************************************************************************* 3 | %% backscattering simulation 4 | %% 测试正弦信号频谱,功率以及功率谱 5 | %% 构造rayleigh衰减信道(如下表格),计算经过信道以及加噪之后信号的功率谱和信号总功率 6 | %% 发射信号,并经过同一rayleigh衰减信道,记忆添加噪声,计算信号的功率谱和总功率 7 | %% @wp 2018-3-7 8 | %%************************************************************************************************* 9 | 10 | % backscattering simulation 11 | % Table B.2.1-2 Extended Pedestrian A model (EPA) rayleigh fading channel model 12 | % Excess tap delay[ns/10] Relative power[dB] 13 | % 0 0.0 14 | % 50 -3.0 15 | % 110 -10.0 16 | % 170 -18.0 17 | % 290 -26.0 18 | % 310 -32.0 19 | 20 | 21 | %% 该部分测试正弦信号经过rayleigh衰减信道,和经过rayleigh衰减信道后并添加部分噪声后的 22 | %% 信号功率的比较 23 | 24 | clc; 25 | clear; 26 | close all; 27 | 28 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 29 | N = 10; % 信号周期内的采样点数 30 | Fs = N*f1; % sampling frequency, 采样频率 31 | T = 1/Fs; % sampling period, 采样周期 32 | L = 20000*N; % length of signal 33 | 34 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 35 | A = 1; % 信号幅值 36 | 37 | %% 构造信号 38 | source = A*sin(2*pi*f1*t); 39 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 40 | power_freqdomain = bandpower(Pxx_hamming, F, 'psd'); 41 | power_freqdomain_db = 10*log10(power_freqdomain/2); 42 | %%************************************************************************************************* 43 | 44 | %% 构造rayleigh信道 45 | % Discrete delays of four-path channel (s) 46 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-10; 47 | 48 | %% Average path gains (dB) 49 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; 50 | 51 | %% Maximum Doppler shift of diffuse components (Hz) 52 | max_Doppler_shift = 50; 53 | 54 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 55 | 56 | %% 经过rayleigh信道,且将保持该信道特性 57 | rayleigh_chan.ResetBeforeFiltering = 0; 58 | data_after_rayleigh = filter(rayleigh_chan,source); 59 | 60 | 61 | %% 功率谱,并计算整个信号的功率 62 | [Pxx_hamming_after_rayleigh, F_after_rayleigh]= periodogram(data_after_rayleigh,... 63 | hamming(length(data_after_rayleigh)),[],Fs,'centered', 'psd'); 64 | power_freqdomain_after_rayleigh = bandpower(Pxx_hamming_after_rayleigh,... 65 | F_after_rayleigh, 'psd'); 66 | power_freqdomain_after_rayleigh_db = 10*log10(power_freqdomain_after_rayleigh/2); 67 | 68 | %% 添加高斯噪声, 69 | SNR = 10*log10(100); 70 | data_after_awgn=awgn(data_after_rayleigh,SNR,'measured'); 71 | 72 | %% 功率谱,并计算tag出接收到的整个信号功率 73 | [Pxx_hamming_after_awgn, F_after_awgn]= periodogram(data_after_awgn,... 74 | hamming(length(data_after_awgn)),[],Fs,'centered', 'psd'); 75 | power_freqdomain_after_awgn = bandpower(Pxx_hamming_after_awgn, F_after_awgn, 'psd'); 76 | power_freqdomain_after_awgn_db = 10*log10(power_freqdomain_after_awgn/2) 77 | 78 | 79 | %%************************************************************************************************* 80 | %% 反射路径 81 | %% 发射因子为0.5 82 | coeffi = 0.5; 83 | data_backscatter = data_after_awgn.*coeffi; 84 | 85 | rayleigh_chan.ResetBeforeFiltering = 0; 86 | backscatter_after_rayleigh = filter(rayleigh_chan,data_backscatter); 87 | 88 | %% 功率谱,并计算backscatter回去的整个信号功率 89 | [Pxx_hamming_after_back, F_after_back]= periodogram(data_backscatter,... 90 | hamming(length(data_backscatter)),[],Fs,'centered', 'psd'); 91 | power_freqdomain_after_back = bandpower(Pxx_hamming_after_back, F_after_back, 'psd'); 92 | power_freqdomain_after_back_db = 10*log10(power_freqdomain_after_back/2); 93 | 94 | %% 返回去的信道中添加高斯噪声, 95 | SNR_back = 10*log10(100); 96 | back_after_awgn=awgn(backscatter_after_rayleigh,SNR_back,'measured'); 97 | 98 | %% 功率谱,并计算接收方的信号功率 99 | [Pxx_hamming_after_back_agwn, F_after_back_agwn]= periodogram(back_after_awgn,... 100 | hamming(length(back_after_awgn)),[],Fs,'centered', 'psd'); 101 | power_freqdomain_after_back_agwn = bandpower(Pxx_hamming_after_back_agwn,... 102 | F_after_back_agwn, 'psd'); 103 | power_freqdomain_after_back_agwn_db = 10*log10(power_freqdomain_after_back_agwn/2) 104 | 105 | figure; 106 | plot(t(1:2000),real(back_after_awgn(1:2000))); 107 | %axis([0 inf -1.5 1.5]); 108 | title('sine signal after channel'); 109 | xlabel(['Time(f=',num2str(f1),')']) 110 | ylabel('Amplitude/V'); 111 | 112 | -------------------------------------------------------------------------------- /key generation in backscatter communication/backscatter_rayleign_v2.m: -------------------------------------------------------------------------------- 1 | %% backscatter_rayleign_v2.m 2 | %%************************************************************************************************* 3 | %% backscattering simulation 4 | %% 和版本1一模一样,只不过修改变量名称,在传输过程仿真无噪声环境 5 | %% 测试正弦信号频谱,功率以及功率谱 6 | %% 构造rayleigh衰减信道(如下表格),计算经过信道以及加噪之后信号的功率谱和信号总功率 7 | %% 发射信号,并经过同一rayleigh衰减信道,记忆添加噪声,计算信号的功率谱和总功率 8 | %% @wp 2018-3-7 9 | %%************************************************************************************************* 10 | % backscattering simulation 11 | % Table B.2.1-2 Extended Pedestrian A model (EPA) rayleigh fading channel model 12 | % Excess tap delay[ns/10] Relative power[dB] 13 | % 0 0.0 14 | % 50 -3.0 15 | % 110 -10.0 16 | % 170 -18.0 17 | % 290 -26.0 18 | % 310 -32.0 19 | 20 | 21 | %% 该部分测试正弦信号经过rayleigh衰减信道,和经过rayleigh衰减信道后并添加部分噪声后的 22 | %% 信号功率的比较 23 | 24 | 25 | clc; 26 | clear; 27 | close all; 28 | 29 | %%************************************************************************************************* 30 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 31 | N = 10; % 信号周期内的采样点数 32 | Fs = N*f1; % sampling frequency, 采样频率 33 | T = 1/Fs; % sampling period, 采样周期 34 | L = 10000*N; % length of signal 35 | 36 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 37 | A = 4; % 信号幅值 38 | 39 | %% 构造初始信号 40 | source = A*sin(2*pi*f1*t); 41 | %% 计算功率谱密度 42 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 43 | power_source = bandpower(Pxx_hamming, F, 'psd'); 44 | power_source_db = 10*log10(power_source/2) 45 | 46 | %%************************************************************************************************* 47 | %% 构造rayleigh信道 48 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 49 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 50 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 51 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 52 | 53 | %% 经过rayleigh信道,且将保持该信道特性 54 | rayleigh_chan.ResetBeforeFiltering = 0; 55 | data_after_rayleigh = filter(rayleigh_chan,source); 56 | 57 | %% 功率谱,并计算通过rayleigh信道后的信号功率 58 | [Pxx_hamming_after_rayleigh, F_after_rayleigh]= periodogram(data_after_rayleigh,... 59 | hamming(length(data_after_rayleigh)),[],Fs,'centered', 'psd'); 60 | power_after_rayleigh = bandpower(Pxx_hamming_after_rayleigh,... 61 | F_after_rayleigh, 'psd'); 62 | power_after_rayleigh_db = 10*log10(power_after_rayleigh/2) 63 | 64 | %%************************************************************************************************* 65 | %% 反射路径 66 | %% 发射因子为0.5 67 | coeffi = 1.0; 68 | data_backscatter = data_after_rayleigh.*coeffi; 69 | 70 | %% 反射后,信号经过再次经过rayleigh信道 71 | rayleigh_chan.ResetBeforeFiltering = 0; 72 | backscatter_after_rayleigh = filter(rayleigh_chan,data_backscatter); 73 | 74 | %% 计算反射之后经过rayleigh信道后的信号功率 75 | [Pxx_hamming_after_back, F_after_back]= periodogram(backscatter_after_rayleigh,... 76 | hamming(length(backscatter_after_rayleigh)),[],Fs,'centered', 'psd'); 77 | power_after_back = bandpower(Pxx_hamming_after_back, F_after_back, 'psd'); 78 | power_after_back_db = 10*log10(power_after_back/2) 79 | 80 | 81 | figure; 82 | plot(t(1:2000),real(backscatter_after_rayleigh(1:2000))); 83 | % axis([0 inf -1.5 1.5]); 84 | title('sine signal after channel'); 85 | xlabel(['Time(f=',num2str(f1),')']) 86 | ylabel('Amplitude/V'); 87 | 88 | -------------------------------------------------------------------------------- /key generation in backscatter communication/power_pt_arrat_v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/power_pt_arrat_v1.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/rayleigh_test.m: -------------------------------------------------------------------------------- 1 | %% raylei_channel.m 2 | %%************************************************************************************************* 3 | %% backscattering simulation 4 | %% 测试正弦信号频谱,功率以及功率谱(三种方法) 5 | %% 构造rayleigh衰减信道(如下表格),FFT变化,加噪声,FFT变化 6 | %% 计算经过信道以及加噪之后信号的功率谱和信号总功率 7 | %% @wp 2018-3-7 8 | %%************************************************************************************************* 9 | 10 | % Table B.2.1-2 Extended Pedestrian A model (EPA) rayleigh fading channel model 11 | % Excess tap delay[ns/10] Relative power[dB] 12 | % 0 0.0 13 | % 30 -1.0 14 | % 70 -2.0 15 | % 90 -3.0 16 | % 110 -8.0 17 | % 190 -17.2 18 | % 410 -20.8 19 | 20 | clc; 21 | clear; 22 | close all; 23 | 24 | f1=900e6; % 信号频率900MHz 25 | N=20; % 信号周期内的采样点数 26 | Fs=N*f1; % sampling frequency, 采样频率 27 | T = 1/Fs; % sampling period, 采样周期 28 | L = 200*N; % length of signal 29 | 30 | t=(0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 31 | A = 1; % 信号幅值 32 | 33 | %% 构造信号 34 | source = A*sin(2*pi*f1*t); 35 | 36 | figure(1); 37 | %% display the signal 38 | plot(t,source); 39 | axis([0 inf -1.5 1.5]); 40 | title('sine signal'); 41 | xlabel(['Time(f=',num2str(f1),')']) 42 | ylabel('Amplitude/V'); 43 | 44 | data_after_fft = fft(source,L); %对信号进行快速fourier变换 45 | mag_fft = abs(data_after_fft); %求得Fourier变换后的幅值 46 | 47 | f = (1:L/2)*Fs/L; %频率序列 48 | %% 绘出随频率变化的振幅 49 | figure(2); 50 | plot(f,mag_fft(1:L/2)*2/L); 51 | xlabel('Frequency/Hz'); 52 | ylabel('Amplitude');title('N=10000');grid on; 53 | 54 | 55 | %%************************************************************************************************* 56 | %% 通过三种不同方式计算信号功率 57 | power_theoretical = (A^2/4)*2; % 理论平均功率 58 | power_theoretical_db = 10*log10(power_theoretical/2) 59 | 60 | power_timedomain = sum(abs(source).^2)/length(source); 61 | power_timedomain_db = 10*log10(power_timedomain/2) 62 | 63 | % 计算该信号的功率谱 64 | figure(3); 65 | periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 66 | 67 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 68 | power_freqdomain = bandpower(Pxx_hamming, F, 'psd'); 69 | power_freqdomain_db = 10*log10(power_freqdomain/2) 70 | %%************************************************************************************************* 71 | 72 | %构造rayleigh信道 73 | delay_vector = [0, 30, 70, 90, 110, 190, 410]*1e-10; % Discrete delays of four-path channel (s) 74 | gain_vector = [0 -1.0 -2.0 -3.0 -8.0 -17.2 -20.8]; % Average path gains (dB) 75 | max_Doppler_shift = 160; % Maximum Doppler shift of diffuse components (Hz) 76 | chan.ResetBeforeFiltering = 0; 77 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 78 | 79 | %% 经过rayleigh信号 80 | data_after_rayleigh = filter(rayleigh_chan,source); 81 | %%************************************************************************************************* 82 | 83 | %% 对信道之后的进行FFT变化,并绘画出频谱图 84 | data_after_rayleigh_fft = fft(data_after_rayleigh,L); %对信号进行快速fourier变换 85 | mag_after_rayleigh_fft = abs(data_after_rayleigh_fft); %求得Fourier变换后的幅值 86 | %% 绘出随频率变化的振幅 87 | figure(4); 88 | plot(f,mag_after_rayleigh_fft(1:L/2)*2/L); 89 | xlabel('Frequency/Hz'); 90 | ylabel('Amplitude');title('N=10000');grid on; 91 | 92 | %% 添加噪声 93 | SNR=10*log10(10); 94 | data_after_awgn=awgn(data_after_rayleigh,SNR,'measured'); 95 | %data_after_awgn = data_after_rayleigh; 96 | 97 | 98 | %% 对噪声之后的进行FFT变化,并绘画出频谱图 99 | data_after_awgn_fft = fft(data_after_awgn,L); %对信号进行快速fourier变换 100 | mag_after_awgn_fft = abs(data_after_awgn_fft); %求得Fourier变换后的幅值 101 | %% 绘出随频率变化的振幅 102 | figure(5); 103 | plot(f,mag_after_awgn_fft(1:L/2)*2/L); 104 | xlabel('Frequency/Hz'); 105 | ylabel('Amplitude');title('N=10000');grid on; 106 | 107 | %%************************************************************************************************* 108 | 109 | % 在计算的过程中已经画出图形,后面都是对图形的调整 110 | [Pxx_hamming_after_awgn, F_after_awgn]= periodogram(data_after_awgn, hamming(length(data_after_awgn)),[],Fs,'centered', 'psd'); 111 | power_freqdomain_after_awgn = bandpower(Pxx_hamming_after_awgn, F_after_awgn, 'psd'); 112 | power_freqdomain_after_awgn_db = 10*log10(power_freqdomain_after_awgn/2) 113 | 114 | figure; 115 | plot(t,real(data_after_awgn)); 116 | %axis([0 inf -1.5 1.5]); 117 | title('sine signal after channel'); 118 | xlabel(['Time(f=',num2str(f1),')']) 119 | ylabel('Amplitude/V'); -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1-Eve-final.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme1-Eve-final.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1-Eve-final_v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme1-Eve-final_v1.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1-Eve-v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme1-Eve-v1.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1_Eve_v1.m: -------------------------------------------------------------------------------- 1 | %*************************************************************** 2 | % scheme1_v1.m 3 | % @wp 2018-3-7 4 | % 仿真方案一: 5 | % 设备与射频源之间的密钥建立 6 | % 射频信号为单一的正弦信号 7 | % 循环测试正弦信号PT与tag模型之间的通信模型,其中包括信号初始功率,tag端的功率,发射回来再PT端的功率 8 | % 9 | % 信号参数: 10 | % 信号频率900MHz,采样点10,采样频率9000MHz,周期10000*10 11 | % 高斯噪声为8dB,信号幅值为4,发射系数为1.0 12 | % 循环1000次 13 | %*************************************************************** 14 | 15 | % Table is a rayleigh fading channel model in indoor 16 | % Excess tap delay[ns] Relative power[dB] 17 | % 0 0.0 18 | % 50 -3.0 19 | % 110 -10.0 20 | % 170 -18.0 21 | % 290 -26.0 22 | % 310 -32.0 23 | 24 | clc; 25 | clear; 26 | close all; 27 | 28 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 29 | N = 8; % 信号周期内的采样点数 30 | Fs = N*f1; % sampling frequency, 采样频率 31 | T = 1/Fs; % sampling period, 采样周期 32 | L = 600*N; % length of signal 33 | 34 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 35 | A = 0.1; % 信号幅值 36 | 37 | %% 设置高斯噪声 38 | SNR_tag = 20; 39 | 40 | %% 构造初始信号 41 | source = A*sin(2*pi*f1*t); 42 | % figure; 43 | % plot(t(1:1000),source(1:1000)); 44 | % title('source signal'); 45 | 46 | %% 计算初始信号的功率 47 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 48 | power_source = bandpower(Pxx_hamming, F, 'psd'); 49 | power_source_db = 10*log10(power_source/2); 50 | %*************************************************************** 51 | 52 | num = 1:600; 53 | power_source_array(num) = power_source; 54 | power_tag_array(num) = 0; 55 | power_pt_array(num) = 0; 56 | 57 | power_tag_array_ptEve(num) = 0; 58 | power_tag_array_AEve(num) = 0; 59 | 60 | for index = num 61 | %%************************************************************ 62 | %% Alice 接收来自PT的信号 63 | %% 构造rayleigh信道 64 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-10; % Discrete delays of four-path channel (s) 65 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 66 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 67 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 68 | 69 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 70 | rayleigh_chan.ResetBeforeFiltering = 0; 71 | data_after_rayleigh = filter(rayleigh_chan,source); 72 | 73 | %% 添加高斯噪声 74 | data_tag = awgn(data_after_rayleigh,SNR_tag,'measured'); 75 | 76 | %% 计算在tag端接收信号的功率 77 | [Pxx_hamming_tag, F_tag] = periodogram(data_tag,hamming(length(data_tag)),[],Fs,'centered','psd'); 78 | power_tag = bandpower(Pxx_hamming_tag,F_tag,'psd'); 79 | power_tag_db = 10*log10(power_tag/2); 80 | 81 | power_tag_array(index) = power_tag; 82 | 83 | %%************************************************************ 84 | %% Eve 接收来自PT的信号 85 | %% 构造rayleigh信道 86 | delay_vector_e = [0, 52, 113, 172, 295, 317]*1e-10; % Discrete delays of four-path channel (s) 87 | gain_vector_e = [0 -3.2 -10.6 -17.3 -26.5 -33.1]; % Average path gains (dB) 88 | max_Doppler_shift_e = 53; % Maximum Doppler shift of diffuse components (Hz) 89 | rayleigh_chan_ptEve = rayleighchan(T,max_Doppler_shift_e,delay_vector_e,gain_vector_e); 90 | 91 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 92 | data_after_rayleigh_ptEve = filter(rayleigh_chan_ptEve,source); 93 | 94 | %% 添加高斯噪声 95 | data_tag_ptEve = awgn(data_after_rayleigh_ptEve,SNR_tag,'measured'); 96 | 97 | %% 计算在tag端接收信号的功率 98 | [Pxx_hamming_tag_ptEve, F_tag_ptEve] = periodogram(data_tag_ptEve,hamming(length(data_tag_ptEve)),[],Fs,'centered','psd'); 99 | power_tag_ptEve = bandpower(Pxx_hamming_tag_ptEve,F_tag_ptEve,'psd'); 100 | power_tag_db_ptEve = 10*log10(power_tag_ptEve/2); 101 | 102 | power_tag_array_ptEve(index) = power_tag_ptEve; 103 | 104 | %%************************************************************ 105 | %% 反射路径 106 | %% 发射因子为0.7 107 | coeffi = 0.2; 108 | data_back = data_tag.*coeffi; 109 | 110 | %% 反射后,信号再次经过rayleigh信道 111 | rayleigh_chan.ResetBeforeFiltering = 0; 112 | back_after_rayleigh = filter(rayleigh_chan,data_back); 113 | rayleigh_chan.ResetBeforeFiltering = 1; 114 | 115 | 116 | %% 添加高斯噪声 117 | data_pt = awgn(back_after_rayleigh,SNR_tag,'measured'); 118 | 119 | %% 计算在tag端接收信号的功率 120 | [Pxx_hamming_pt, F_pt] = periodogram(data_pt,hamming(length(data_pt)),[],Fs,'centered','psd'); 121 | power_pt = bandpower(Pxx_hamming_pt,F_pt,'psd'); 122 | power_pt_db = 10*log10(power_pt/2); 123 | 124 | power_pt_array(index) = power_pt; 125 | 126 | %%************************************************************ 127 | %%Eve 接收来自Alice的信号 128 | %% 构造rayleigh信道 129 | delay_vector_ae = [0, 35, 89, 165, 271, 326]*1e-10; % Discrete delays of four-path channel (s) 130 | gain_vector_ae = [0 -1.8 -8.0 -15.9 -25.0 -31.4]; % Average path gains (dB) 131 | max_Doppler_shift_ae = 30; % Maximum Doppler shift of diffuse components (Hz) 132 | rayleigh_chan_AEve = rayleighchan(T,max_Doppler_shift_ae,delay_vector_ae,gain_vector_ae); 133 | 134 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 135 | data_after_rayleigh_AEve = filter(rayleigh_chan_AEve,data_back); 136 | 137 | %% 添加高斯噪声 138 | data_tag_AEve = awgn(data_after_rayleigh_AEve,SNR_tag,'measured'); 139 | 140 | %% 计算在tag端接收信号的功率 141 | [Pxx_hamming_tag_AEve, F_tag_AEve] = periodogram(data_tag_AEve,hamming(length(data_tag_AEve)),[],Fs,'centered','psd'); 142 | power_tag_AEve = bandpower(Pxx_hamming_tag_AEve,F_tag_AEve,'psd'); 143 | power_tag_db_AEve = 10*log10(power_tag_AEve/2); 144 | 145 | power_tag_array_AEve(index) = power_tag_AEve; 146 | end 147 | 148 | figure; 149 | plot(num(1:100),10*log10(power_tag_array(1:100)),'b*-'); 150 | hold on; 151 | plot(num(1:100),10*log10(power_pt_array(1:100)),'r+-'); 152 | % hold on; 153 | % plot(num(1:100),10*log10(power_tag_array_AEve(1:100)),'k*-'); 154 | % hold on; 155 | % plot(num(1:100),10*log10(power_tag_array_ptEve(1:100)),'k'); 156 | legend('Alice','PT'); 157 | ylabel('RSSI(dB)'); 158 | xlabel('Samples'); 159 | grid on; 160 | %,'Reflection sensed at Eve' 161 | 162 | figure; 163 | plot(num(1:100),10*log10(power_tag_array(1:100)),'b*-'); 164 | hold on; 165 | plot(num(1:100),10*log10(power_pt_array(1:100)),'r+-'); 166 | hold on; 167 | plot(num(1:100),10*log10(power_tag_array_AEve(1:100)),'ks-'); 168 | % hold on; 169 | % plot(num(1:100),10*log10(power_tag_array_ptEve(1:100)),'k'); 170 | legend('Alice','PT','reflection sensed at Eve'); 171 | ylabel('RSSI(dB)'); 172 | xlabel('Samples'); 173 | grid on; 174 | r = corr2(power_tag_array,power_pt_array) 175 | 176 | result1 = power_source_array.*power_pt_array/0.7; 177 | result2 = power_tag_array.^2; 178 | r = corr2(result1,result2) 179 | 180 | r = corr2(power_tag_array,power_tag_array_ptEve) 181 | r = corr2(power_pt_array,power_tag_array_AEve) 182 | 183 | 184 | % figure; 185 | % plot(num(1:100),10*log10(result1(1:100)),'r-'); 186 | % hold on; 187 | % plot(num(1:100),10*log10(result2(1:100)),'b-'); 188 | -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1_v1.m: -------------------------------------------------------------------------------- 1 | %*************************************************************** 2 | % scheme1_v1.m 3 | % @wp 2018-3-7 4 | % 仿真方案一: 5 | % 设备与射频源之间的密钥建立 6 | % 射频信号为单一的正弦信号 7 | % 循环测试正弦信号PT与tag模型之间的通信模型,其中包括信号初始功率,tag端的功率,发射回来再PT端的功率 8 | % 9 | % 信号参数: 10 | % 信号频率900MHz,采样点10,采样频率9000MHz,周期10000*10 11 | % 高斯噪声为8dB,信号幅值为4,发射系数为1.0 12 | % 循环1000次 13 | %*************************************************************** 14 | 15 | % Table is a rayleigh fading channel model in indoor 16 | % Excess tap delay[ns] Relative power[dB] 17 | % 0 0.0 18 | % 50 -3.0 19 | % 110 -10.0 20 | % 170 -18.0 21 | % 290 -26.0 22 | % 310 -32.0 23 | 24 | clc; 25 | clear; 26 | close all; 27 | 28 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 29 | N = 10; % 信号周期内的采样点数 30 | Fs = N*f1; % sampling frequency, 采样频率 31 | T = 1/Fs; % sampling period, 采样周期 32 | L = 10000*N; % length of signal 33 | 34 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 35 | A = 4; % 信号幅值 36 | 37 | %% 设置高斯噪声 38 | SNR_tag = 8; 39 | 40 | %% 构造初始信号 41 | source = A*sin(2*pi*f1*t); 42 | figure; 43 | plot(t(1:1000),source(1:1000)); 44 | title('source signal'); 45 | 46 | %% 计算初始信号的功率 47 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 48 | power_source = bandpower(Pxx_hamming, F, 'psd'); 49 | power_source_db = 10*log10(power_source/2); 50 | %*************************************************************** 51 | % 52 | num = 1:1000; 53 | power_source_array(num) = power_source_db; 54 | power_tag_array(num) = 0; 55 | power_pt_array(num) = 0; 56 | 57 | for index = num 58 | %% 构造rayleigh信道 59 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 60 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 61 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 62 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 63 | 64 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 65 | rayleigh_chan.ResetBeforeFiltering = 0; 66 | data_after_rayleigh = filter(rayleigh_chan,source); 67 | 68 | %% 添加高斯噪声 69 | data_tag = awgn(data_after_rayleigh,SNR_tag,'measured'); 70 | 71 | %% 计算在tag端接收信号的功率 72 | [Pxx_hamming_tag, F_tag] = periodogram(data_tag,hamming(length(data_tag)),[],Fs,'centered','psd'); 73 | power_tag = bandpower(Pxx_hamming_tag,F_tag,'psd'); 74 | power_tag_db = 10*log10(power_tag/2); 75 | 76 | power_tag_array(index) = power_tag_db; 77 | 78 | %%************************************************************ 79 | %% 反射路径 80 | %% 发射因子为0.5 81 | coeffi = 1.0; 82 | data_back = data_tag.*coeffi; 83 | 84 | %% 反射后,信号再次经过rayleigh信道 85 | rayleigh_chan.ResetBeforeFiltering = 0; 86 | back_after_rayleigh = filter(rayleigh_chan,data_back); 87 | 88 | 89 | %% 添加高斯噪声 90 | data_pt = awgn(back_after_rayleigh,SNR_tag,'measured'); 91 | 92 | %% 计算在tag端接收信号的功率 93 | [Pxx_hamming_pt, F_pt] = periodogram(data_pt,hamming(length(data_pt)),[],Fs,'centered','psd'); 94 | power_pt = bandpower(Pxx_hamming_pt,F_pt,'psd'); 95 | power_pt_db = 10*log10(power_pt/2); 96 | 97 | power_pt_array(index) = power_pt_db; 98 | 99 | end 100 | 101 | figure; 102 | plot(num(1:200),power_pt_array(1:200),'*-'); 103 | hold on; 104 | plot(num(1:200),power_tag_array(1:200),'+-'); 105 | legend('RSS in PT','RSS in tag'); 106 | 107 | result1 = power_source_array+power_pt_array; 108 | result2 = power_tag_array*2; 109 | 110 | figure; 111 | plot(num(1:200),result1(1:200),'*-'); 112 | hold on; 113 | plot(num(1:200),result2(1:200),'+-'); 114 | 115 | 116 | r = corr2(power_pt_array,power_tag_array) 117 | 118 | r = corr2(result1,result2) -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1_v2.m: -------------------------------------------------------------------------------- 1 | %*************************************************************** 2 | % scheme1_v1.m 3 | % @wp 2018-3-7 4 | % 仿真方案一: 5 | % 设备与射频源之间的密钥建立 6 | % 射频信号为两个不同频率的正弦信号的叠加 7 | % 循环测试正弦信号PT与tag模型之间的通信模型,其中包括信号初始功率,tag端的功率,发射回来再PT端的功率 8 | % 9 | % 信号参数: 10 | % 信号频率900MHz,采样点10,采样频率9000MHz,周期10000*10 11 | % 高斯噪声为8dB,信号幅值为4,发射系数为1.0 12 | % 循环1000次 13 | %*************************************************************** 14 | 15 | % Table is a rayleigh fading channel model in indoor 16 | % Excess tap delay[ns] Relative power[dB] 17 | % 0 0.0 18 | % 50 -3.0 19 | % 110 -10.0 20 | % 170 -18.0 21 | % 290 -26.0 22 | % 310 -32.0 23 | 24 | clc; 25 | clear; 26 | close all; 27 | 28 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 29 | f2 = 950e6; % 信号频率900MHz,信号周期为10/9 ns 30 | N = 10; % 信号周期内的采样点数 31 | Fs = N*f1; % sampling frequency, 采样频率 32 | T = 1/Fs; % sampling period, 采样周期 33 | L = 100*N; % length of signal 34 | 35 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 36 | A = 4/2; % 信号幅值 37 | 38 | %% 设置高斯噪声 39 | SNR_tag = 8; 40 | 41 | %% 构造初始信号 42 | source = A*sin(2*pi*f1*t)+A*sin(2*pi*f2*t); 43 | figure; 44 | plot(t(1:1000),source(1:1000)); 45 | title('source signal'); 46 | 47 | %% 计算初始信号的功率 48 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 49 | power_source = bandpower(Pxx_hamming, F, 'psd'); 50 | power_source_db = 10*log10(power_source/2); 51 | %*************************************************************** 52 | % 53 | num = 1:200; 54 | power_source_array(num) = power_source_db; 55 | power_tag_array(num) = 0; 56 | power_pt_array(num) = 0; 57 | 58 | for index = num 59 | 60 | %% 构造rayleigh信道 61 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 62 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 63 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 64 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 65 | 66 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 67 | rayleigh_chan.ResetBeforeFiltering = 0; 68 | data_after_rayleigh = filter(rayleigh_chan,source); 69 | 70 | %% 添加高斯噪声 71 | data_tag = awgn(data_after_rayleigh,SNR_tag,'measured'); 72 | 73 | %% 计算在tag端接收信号的功率 74 | [Pxx_hamming_tag, F_tag] = periodogram(data_tag,hamming(length(data_tag)),[],Fs,'centered','psd'); 75 | power_tag = bandpower(Pxx_hamming_tag,F_tag,'psd'); 76 | power_tag_db = 10*log10(power_tag/2); 77 | 78 | power_tag_array(index) = power_tag_db; 79 | 80 | %%************************************************************ 81 | %% 反射路径 82 | %% 发射因子为0.5 83 | coeffi = 1.0; 84 | data_back = data_tag.*coeffi; 85 | 86 | %% 反射后,信号再次经过rayleigh信道 87 | rayleigh_chan.ResetBeforeFiltering = 0; 88 | back_after_rayleigh = filter(rayleigh_chan,data_back); 89 | 90 | 91 | %% 添加高斯噪声 92 | data_pt = awgn(back_after_rayleigh,SNR_tag,'measured'); 93 | 94 | %% 计算在tag端接收信号的功率 95 | [Pxx_hamming_pt, F_pt] = periodogram(data_pt,hamming(length(data_pt)),[],Fs,'centered','psd'); 96 | power_pt = bandpower(Pxx_hamming_pt,F_pt,'psd'); 97 | power_pt_db = 10*log10(power_pt/2); 98 | 99 | power_pt_array(index) = power_pt_db; 100 | 101 | end 102 | 103 | figure; 104 | plot(num(1:200),power_pt_array(1:200),'r-'); 105 | hold on; 106 | plot(num(1:200),power_tag_array(1:200),'b-'); 107 | legend('RSS in PT','RSS in tag'); 108 | 109 | result1 = power_source_array+power_pt_array; 110 | result2 = power_tag_array*2; 111 | 112 | figure; 113 | plot(num(1:200),result1(1:200),'*-'); 114 | hold on; 115 | plot(num(1:200),result2(1:200),'+-'); 116 | 117 | 118 | r = corr2(power_pt_array,power_tag_array) 119 | 120 | r = corr2(result1,result2) -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme1_v2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme1_v2.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme2-Eve-final.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme2-Eve-final.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme2_test.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | 10 | 11 | %% 仿真方案二,设备之间的密钥建立,但是在tag能够区分整个信号时,即不叠加两个信号 12 | 13 | clc; 14 | clear; 15 | close all; 16 | 17 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 18 | N = 10; % 信号周期内的采样点数 19 | Fs = N*f1; % sampling frequency, 采样频率 20 | T = 1/Fs; % sampling period, 采样周期 21 | L = 1000*N; % length of signal 22 | 23 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 24 | A = 4; % 信号幅值 25 | 26 | 27 | %% 构造初始信号 28 | source = A*sin(2*pi*f1*t); 29 | 30 | %% 计算初始信号的功率 31 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 32 | power_source = bandpower(Pxx_hamming, F, 'psd'); 33 | power_source_db = 10*log10(power_source/2); 34 | 35 | 36 | num = 1:10; 37 | 38 | power_source_array(num) = power_source_db; 39 | 40 | power_tag_array(num) = 0; 41 | 42 | power_pt_array(num) = 0; 43 | 44 | for index = num 45 | 46 | %% 测试PT传输信号到Alice时的信号功率 47 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 48 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 49 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 50 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 51 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 52 | 53 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 54 | rayleigh_chan_a.ResetBeforeFiltering = 0; 55 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 56 | 57 | %% 设置高斯噪声与信号的信噪比 58 | SNR_tag_a = 8; 59 | %% 添加高斯噪声 60 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 61 | 62 | %% 计算在tag端接收信号的功率 63 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 64 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 65 | power_tag_a_db = 10*log10(power_tag_a/2); 66 | 67 | power_tag_a_array(index) = power_tag_a; 68 | 69 | 70 | %%********************************************************************************************** 71 | %% 测试PT传输信号到Bob时的信号功率 72 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 73 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-9; % Discrete delays of four-path channel (s) 74 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 75 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 76 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 77 | 78 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 79 | rayleigh_chan_b.ResetBeforeFiltering = 0; 80 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 81 | 82 | %% 设置高斯噪声与信号的信噪比 83 | SNR_tag_b = 9; 84 | %% 添加高斯噪声 85 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 86 | 87 | %% 计算在tag端接收信号的功率 88 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 89 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 90 | power_tag_b_db = 10*log10(power_tag_b/2); 91 | 92 | power_tag_b_array(index) = power_tag_b; 93 | 94 | 95 | %%********************************************************************************************** 96 | %% Alice的反射路径,将信号反射给Bob 97 | coeffi_a = 1.0; %% 反射因子 98 | data_a_back = data_tag_a.*coeffi_a; 99 | 100 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 101 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 102 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 103 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 104 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 105 | 106 | %% 反射后,信号经过rayleigh信道 107 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 108 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 109 | 110 | %% 为叠加信号添加高斯噪声 111 | SNR_tag_b = 9; 112 | data_b = awgn(back_after_rayleigh_ab,SNR_tag_b,'measured'); 113 | 114 | %% 计算在Bob端接收信号的功率 115 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 116 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 117 | power_b_db = 10*log10(power_b/2); 118 | 119 | power_b_array(index) = power_b; 120 | 121 | %%********************************************************************************************** 122 | %% bob的反射路径,将信号反射给Alice 123 | coeffi_b = 1.0; %% 反射因子 124 | data_b_back = data_tag_b.*coeffi_b; 125 | 126 | %% 使用与Alice到Bob之间的信道模型 127 | % %% 构造rayleigh信道,表示Alice与Bob之间的信道 128 | % delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 129 | % gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 130 | % max_Doppler_shift_ab = 10; % Maximum Doppler shift of diffuse components (Hz) 131 | % rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 132 | 133 | %% 反射后,信号经过rayleigh信道 134 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 135 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 136 | 137 | %% 为叠加信号添加高斯噪声 138 | SNR_tag_a = 8; 139 | data_a = awgn(back_after_rayleigh_ba,SNR_tag_a,'measured'); 140 | 141 | 142 | %% 计算在Alice端接收信号的功率 143 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 144 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 145 | power_a_db = 10*log10(power_a/2); 146 | 147 | power_a_array(index) = power_a; 148 | 149 | end 150 | 151 | figure; 152 | plot(num,power_tag_a_array); 153 | hold on; 154 | plot(num,power_tag_b_array); 155 | hold on; 156 | plot(num,power_b_array); 157 | hold on; 158 | plot(num,power_a_array); 159 | legend('PT-a','pt-b','total-b','total-a'); 160 | grid on; 161 | 162 | 163 | figure; 164 | plot(num,power_a_array.*power_tag_a_array); 165 | hold on; 166 | plot(num,power_b_array.*power_tag_b_array); 167 | legend('alice','bob'); 168 | grid on; 169 | 170 | %% 计算序列的相关性 171 | r = corr2(power_b_array,power_a_array) 172 | r = corr2(power_a_array.*power_tag_a_array,power_b_array.*power_tag_b_array) -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme2_test2.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | %% 之后的信号都这个模型的基础上进行的修改 10 | 11 | %% 仿真方案二,设备之间的密钥建立 12 | clc; 13 | clear; 14 | close all; 15 | 16 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 17 | N = 10; % 信号周期内的采样点数 18 | Fs = N*f1; % sampling frequency, 采样频率 19 | T = 1/Fs; % sampling period, 采样周期 20 | L = 100*N; % length of signal 21 | 22 | t = (0:(L-1))*T; % 采样时间s,fs的值越大,出来的波形失真越小 23 | A = 0.2; % 信号幅值 24 | 25 | %% 构造调制1和-1序列 26 | f_seq = 22.5e6; %% 45MHz 27 | value = 1; 28 | for index = 1:L 29 | base_signal(index) = value; 30 | if mod(index, (Fs/f_seq)/2) == 0 31 | value = 0-value; 32 | end 33 | end 34 | 35 | % base_signal=square(2*pi*f_seq*t); 36 | % sum(base_signal) 37 | 38 | 39 | 40 | %% 构造初始信号 41 | source = A*sin(2*pi*f1*t); 42 | 43 | % plot(t(1:200),source(1:200),t(1:200),base_signal(1:200)) 44 | 45 | %% 计算初始信号的功率 46 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 47 | power_source = bandpower(Pxx_hamming, F, 'psd'); 48 | power_source_db = 10*log10(power_source/2); 49 | 50 | 51 | num = 1:1000; 52 | 53 | power_source_array(num) = power_source; 54 | 55 | power_tag_a_array(num) = 0; 56 | power_tag_b_array(num) = 0; 57 | 58 | 59 | power_ab_array(num) = 0; 60 | power_ba_array(num) = 0; 61 | 62 | 63 | power_tag_e_array(num) = 0; 64 | power_ae_array(num) = 0; 65 | 66 | 67 | for index = num 68 | 69 | %%********************************************************************************************** 70 | %% 测试PT传输信号到Alice时的信号功率 71 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 72 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-10; % Discrete delays of four-path channel (s) 73 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 74 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 75 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 76 | 77 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 78 | rayleigh_chan_a.ResetBeforeFiltering = 0; 79 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 80 | 81 | %% 设置高斯噪声与信号的信噪比 82 | SNR_tag_a = 10; 83 | %% 添加高斯噪声 84 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 85 | 86 | %% 计算在tag端接收信号的功率 87 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 88 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 89 | power_tag_a_db = 10*log10(power_tag_a/2); 90 | 91 | power_tag_a_array(index) = power_tag_a; 92 | 93 | 94 | %%********************************************************************************************** 95 | %% 测试PT传输信号到Bob时的信号功率 96 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 97 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-10; % Discrete delays of four-path channel (s) 98 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 99 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 100 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 101 | 102 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 103 | rayleigh_chan_b.ResetBeforeFiltering = 0; 104 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 105 | 106 | %% 设置高斯噪声与信号的信噪比 107 | SNR_tag_b = 9; 108 | %% 添加高斯噪声 109 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 110 | 111 | %% 计算在tag端接收信号的功率 112 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 113 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 114 | power_tag_b_db = 10*log10(power_tag_b/2); 115 | 116 | power_tag_b_array(index) = power_tag_b; 117 | 118 | %%********************************************************************************************** 119 | %% 测试PT传输信号到Eve时的信号功率 120 | %% 构造rayleigh信道,表示PT与Eve之间的信道 121 | delay_vector_e = [0, 68, 130, 169, 295, 333]*1e-10; % Discrete delays of four-path channel (s) 122 | gain_vector_e = [0 -4.5 -11.6 -21.7 -29.9 -39.4]; % Average path gains (dB) 123 | max_Doppler_shift_e = 20; % Maximum Doppler shift of diffuse components (Hz) 124 | rayleigh_chan_e = rayleighchan(T,max_Doppler_shift_e,delay_vector_e,gain_vector_e); 125 | 126 | data_after_rayleigh_e = filter(rayleigh_chan_e,source); 127 | 128 | %% 计算在Eve端接收信号的功率 129 | [Pxx_hamming_tag_e, F_tag_e] = periodogram(data_after_rayleigh_e,hamming(length(data_after_rayleigh_e)),[],Fs,'centered','psd'); 130 | power_tag_e = bandpower(Pxx_hamming_tag_e,F_tag_e,'psd'); 131 | power_tag_e_db = 10*log10(power_tag_e/2); 132 | 133 | power_e_array(index) = power_tag_e; 134 | 135 | 136 | %%********************************************************************************************** 137 | %% Alice的反射路径,将信号反射给Bob 138 | coeffi_a = 0.7; %% 反射因子 139 | data_a_coeffi = data_tag_a.*coeffi_a; 140 | 141 | %% 进行ASK调制,使用已经设置好的方波序列 142 | data_a_back = data_a_coeffi.*base_signal; 143 | 144 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 145 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-10; % Discrete delays of four-path channel (s) 146 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 147 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 148 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 149 | 150 | %% 反射后,信号经过rayleigh信道,设置为0,用于Bob发射给Alice 151 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 152 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 153 | 154 | %% Bob接收的信号为Alice反射信号和PT直传信号的叠加 155 | data_total_b = back_after_rayleigh_ab + data_after_rayleigh_b; 156 | 157 | %% 为叠加信号添加高斯噪声 158 | SNR_tag_b = 10; 159 | data_b = awgn(data_total_b,SNR_tag_b,'measured'); 160 | 161 | %% 计算在Bob端接收信号的功率 162 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 163 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 164 | power_b_db = 10*log10(power_b/2); 165 | 166 | power_b_array(index) = power_b; 167 | 168 | 169 | %%********************************************************************************************** 170 | %% 构造rayleigh信道,表示Alice与Eve之间的信道 171 | delay_vector_ae = [0, 8, 21, 32, 43, 59]*1e-10; % Discrete delays of four-path channel (s) 172 | gain_vector_ae = [0 -1.8 -6.4 -12.1 -20.8 -30.2]; % Average path gains (dB) 173 | max_Doppler_shift_ae = 63; % Maximum Doppler shift of diffuse components (Hz) 174 | rayleigh_chan_ae = rayleighchan(T,max_Doppler_shift_ae,delay_vector_ae,gain_vector_ae); 175 | 176 | data_after_rayleigh_ae = filter(rayleigh_chan_ae,data_a_back); 177 | 178 | %% 计算在Eve端接收信号的功率 179 | [Pxx_hamming_tag_ae, F_tag_ae] = periodogram(data_after_rayleigh_ae,hamming(length(data_after_rayleigh_ae)),[],Fs,'centered','psd'); 180 | power_tag_ae = bandpower(Pxx_hamming_tag_ae,F_tag_ae,'psd'); 181 | power_tag_ae_db = 10*log10(power_tag_ae/2); 182 | 183 | power_ae_array(index) = power_tag_ae; 184 | 185 | %%********************************************************************************************** 186 | %% bob的反射路径,将信号反射给Alice 187 | coeffi_b = 0.7; %% 反射因子 188 | data_b_coeffi = data_tag_b.*coeffi_b; 189 | 190 | %% 进行ASK调制,使用已经设置好的方波序列 191 | data_b_back = data_b_coeffi.*base_signal; 192 | 193 | %% 反射后,信号经过rayleigh信道 194 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 195 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 196 | rayleigh_chan_ab.ResetBeforeFiltering = 1; 197 | 198 | %% Alice接收的信号为Bob反射信号和PT直传信号的叠加 199 | data_total_a = back_after_rayleigh_ba + data_after_rayleigh_a; 200 | 201 | %% 为叠加信号添加高斯噪声 202 | SNR_tag_a = 8; 203 | data_a = awgn(data_total_a,SNR_tag_a,'measured'); 204 | 205 | 206 | %% 计算在Alice端接收信号的功率 207 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 208 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 209 | power_a_db = 10*log10(power_a/2); 210 | 211 | power_a_array(index) = power_a; 212 | 213 | end 214 | 215 | %% 第一步中Alice 与Bob之间的相关关系 216 | figure; 217 | plot(num(1:200),10*log10(power_tag_a_array(1:200)./2)); 218 | hold on; 219 | plot(num(1:200),10*log10(power_tag_b_array(1:200)./2)); 220 | grid on; 221 | legend('PT-a','PT-b'); 222 | r = corr2(power_tag_a_array,power_tag_b_array) 223 | 224 | %% 最后总信号,Alice 与Bob之间的相关关系 225 | figure; 226 | plot(num(1:200),10*log10(power_b_array(1:200)./2)); 227 | hold on; 228 | plot(num(1:200),10*log10(power_a_array(1:200)./2)); 229 | grid on; 230 | legend('RSS(Bob)','RSS(Alice)'); 231 | xlabel('RSS(dB)'); 232 | ylabel('Samples'); 233 | %% 计算序列的相关性 234 | r = corr2(power_b_array,power_a_array) 235 | 236 | 237 | %% 信号处理后,Alice 与Bob之间的相关关系 238 | alice = (power_a_array-power_tag_a_array).*power_tag_a_array; 239 | bob = (power_b_array-power_tag_b_array).*power_tag_b_array; 240 | eve = power_ae_array.*power_e_array; 241 | cor = corr2(alice,bob) 242 | cor = corr2(bob,eve) 243 | figure; 244 | plot(num(1:100),10*log10(alice(1:100))./2,'r*-'); 245 | hold on; 246 | plot(num(1:100),10*log10(bob(1:100))./2,'b+-'); 247 | hold on; 248 | plot(num(1:100),10*log10(eve(1:100))./2,'ks-'); 249 | ylabel('RSSI(dB)'); 250 | xlabel('Samples') 251 | legend('alice','bob','Eve'); 252 | grid on; -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme2_v1.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | 10 | 11 | %% 仿真方案二,设备之间的密钥建立 12 | 13 | clc; 14 | clear; 15 | close all; 16 | 17 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 18 | f2 = 950e6; % 信号频率900MHz,信号周期为10/9 ns 19 | N = 10; % 信号周期内的采样点数 20 | Fs = N*f1; % sampling frequency, 采样频率 21 | T = 1/Fs; % sampling period, 采样周期 22 | L = 1000*N; % length of signal 23 | 24 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 25 | A = 4; % 信号幅值 26 | 27 | 28 | %% 构造初始信号 29 | source = A*sin(2*pi*f1*t) + A*sin(2*pi*f2*t); 30 | 31 | %% 计算初始信号的功率 32 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 33 | power_source = bandpower(Pxx_hamming, F, 'psd'); 34 | power_source_db = 10*log10(power_source/2); 35 | 36 | 37 | num = 1:100; 38 | 39 | power_source_array(num) = power_source_db; 40 | 41 | power_tag_array(num) = 0; 42 | 43 | power_pt_array(num) = 0; 44 | 45 | for index = num 46 | 47 | %% 测试PT传输信号到Alice时的信号功率 48 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 49 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 50 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 51 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 52 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 53 | 54 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 55 | rayleigh_chan_a.ResetBeforeFiltering = 0; 56 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 57 | 58 | %% 设置高斯噪声与信号的信噪比 59 | SNR_tag_a = 8; 60 | %% 添加高斯噪声 61 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 62 | 63 | %% 计算在tag端接收信号的功率 64 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 65 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 66 | power_tag_a_db = 10*log10(power_tag_a/2); 67 | 68 | power_tag_a_array(index) = power_tag_a; 69 | 70 | 71 | %%********************************************************************************************** 72 | %% 测试PT传输信号到Bob时的信号功率 73 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 74 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-9; % Discrete delays of four-path channel (s) 75 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 76 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 77 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 78 | 79 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 80 | rayleigh_chan_b.ResetBeforeFiltering = 0; 81 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 82 | 83 | %% 设置高斯噪声与信号的信噪比 84 | SNR_tag_b = 9; 85 | %% 添加高斯噪声 86 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 87 | 88 | %% 计算在tag端接收信号的功率 89 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 90 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 91 | power_tag_b_db = 10*log10(power_tag_b/2); 92 | 93 | power_tag_b_array(index) = power_tag_b; 94 | 95 | 96 | %%********************************************************************************************** 97 | %% Alice的反射路径,将信号反射给Bob 98 | coeffi_a = 1.0; %% 反射因子 99 | data_a_back = data_tag_a.*coeffi_a; 100 | 101 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 102 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 103 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 104 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 105 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 106 | 107 | %% 反射后,信号经过rayleigh信道 108 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 109 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 110 | 111 | %% Bob接收的信号为Alice反射信号和PT直传信号的叠加 112 | data_total_b = back_after_rayleigh_ab + data_after_rayleigh_b; 113 | 114 | %% 为叠加信号添加高斯噪声 115 | SNR_tag_b = 9; 116 | data_b = awgn(data_total_b,SNR_tag_b,'measured'); 117 | 118 | %% 计算在Bob端接收信号的功率 119 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 120 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 121 | power_b_db = 10*log10(power_b/2); 122 | 123 | power_b_array(index) = power_b; 124 | 125 | %%********************************************************************************************** 126 | %% bob的反射路径,将信号反射给Alice 127 | coeffi_b = 1.0; %% 反射因子 128 | data_b_back = data_tag_b.*coeffi_b; 129 | 130 | %% 使用与Alice到Bob之间的信道模型 131 | % %% 构造rayleigh信道,表示Alice与Bob之间的信道 132 | % delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 133 | % gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 134 | % max_Doppler_shift_ab = 10; % Maximum Doppler shift of diffuse components (Hz) 135 | % rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 136 | 137 | %% 反射后,信号经过rayleigh信道 138 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 139 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 140 | 141 | %% Alice接收的信号为Bob反射信号和PT直传信号的叠加 142 | data_total_a = back_after_rayleigh_ba + data_after_rayleigh_a; 143 | 144 | %% 为叠加信号添加高斯噪声 145 | SNR_tag_a = 8; 146 | data_a = awgn(data_total_a,SNR_tag_a,'measured'); 147 | 148 | 149 | %% 计算在Alice端接收信号的功率 150 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 151 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 152 | power_a_db = 10*log10(power_a/2); 153 | 154 | power_a_array(index) = power_a; 155 | 156 | end 157 | 158 | figure; 159 | plot(num,power_tag_a_array); 160 | hold on; 161 | plot(num,power_tag_b_array); 162 | hold on; 163 | plot(num,power_b_array); 164 | hold on; 165 | plot(num,power_a_array); 166 | legend('PT-a','pt-b','total-b','total-a'); 167 | grid on; 168 | 169 | 170 | figure; 171 | plot(num,(power_a_array-power_tag_a_array).*power_tag_a_array); 172 | hold on; 173 | plot(num,(power_b_array-power_tag_b_array).*power_tag_b_array); 174 | legend('alice','bob'); 175 | grid on; 176 | 177 | %% 计算序列的相关性 178 | r = corr2(power_b_array,power_a_array) 179 | -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme_test2_array_314.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme_test2_array_314.mat -------------------------------------------------------------------------------- /key generation in backscatter communication/scheme_test2_array_v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/key generation in backscatter communication/scheme_test2_array_v1.mat -------------------------------------------------------------------------------- /rake receiver/mgen.m: -------------------------------------------------------------------------------- 1 | %m sequence generation/mgen.m 2 | function[out] = mgen(g,state,N) 3 | %test g = 11;state = 3;N = 15; 4 | 5 | gen = dec2bin(g)-48; 6 | M = length(gen); 7 | curState = dec2bin(state,M-1) - 48; 8 | 9 | for k = 1:N 10 | out(k) = curState(M-1); 11 | a = rem(sum(gen(2:end).*curState),2); 12 | curState = [a curState(1:M-2)]; 13 | end -------------------------------------------------------------------------------- /rake receiver/rake_3path_max.m: -------------------------------------------------------------------------------- 1 | %Rake reciever/rake.m 2 | % 3 | clear all; 4 | close all; 5 | Tc = 1; 6 | N = 128; 7 | gx = '1000010111000101';%g(x) = x^15+x^13+x^9+x^8+x^7+x^5+1 8 | g = bin2dec(gx); 9 | state = 1; 10 | L = 2^13; 11 | 12 | EcN0dB = -21:-14; %different noise value 13 | 14 | for k = 1:length(EcN0dB) 15 | error(k) = 0;%the number of error bits 16 | total(k) = 0;%the total number of transmission bits 17 | sigma(k) = sqrt(10.^(-EcN0dB(k)/10)/2); 18 | while(error(k)<100) 19 | %3 channels 20 | p1 = sqrt(0.5/2)*(randn(1,L)+j*randn(1,L)); 21 | p2 = sqrt(0.3/2)*(randn(1,L)+j*randn(1,L)); 22 | p3 = sqrt(0.2/2)*(randn(1,L)+j*randn(1,L)); 23 | %corresponding relay times 24 | t1 = 0; 25 | t2 = 1; 26 | t3 = 2; 27 | 28 | pt = mgen(g,state,L+t3);%call the M sequence generation function 29 | pt = 2*pt-1; 30 | 31 | %generate 64 random bits (-1,0,1) 32 | d = sign(randn(1,L/N)); 33 | 34 | %insert the 127 0s in the sequence and expand 64 bits to 128*64 35 | dd = sigexpand(d,N); 36 | s = conv(dd,ones(1,N)); %convolution 37 | st = s(1:L+t3).*pt(1:L+t3); %spread frequency 38 | 39 | %add the noise 40 | z = sigma(k)*(randn(1,L)+j*randn(1,L)); 41 | 42 | rt = st(1:L).*p1 + st(t2+1:L+t2).*p2 + st(t3+1:t3+L).*p3 + z; 43 | 44 | 45 | %rake receiving 46 | r1 = rt.*conj(p1).*pt(1:L); 47 | r2 = rt.*conj(p2).*pt(t2+1:L+t2); 48 | r3 = rt.*conj(p3).*pt(t3+1:L+t3); 49 | 50 | %integration 51 | r1 = reshape(r1,N,L/N);y1 = sum(r1); 52 | r2 = reshape(r2,N,L/N);y2 = sum(r2); 53 | r3 = reshape(r3,N,L/N);y3 = sum(r3); 54 | 55 | %sum 56 | y = y1 + y2 + y3;%????? 57 | 58 | %decode 59 | dc = sign(real(y)); 60 | 61 | error(k) = error(k) + sum(abs((d-dc))/2); 62 | total(k) = total(k) + L/N; 63 | BitErrorRate(k) = error(k)/total(k); 64 | end 65 | end 66 | 67 | %draw the curved line about the bit error rate 68 | semilogy(EcN0dB,BitErrorRate); 69 | grid on; -------------------------------------------------------------------------------- /rake receiver/sigexpand.m: -------------------------------------------------------------------------------- 1 | %insert the M-1 0s in the sequence and expand length of d to len(d)*M 2 | function[out] = sigexpand(d,M) 3 | N = length(d); 4 | out = zeros(M,N); 5 | out(1,:) = d; 6 | out = reshape(out,1,M*N); -------------------------------------------------------------------------------- /rayleigh channel simulation/AM.m: -------------------------------------------------------------------------------- 1 | % AM modulation 2 | 3 | fs = 1e5; 4 | t = (0:1/fs:100)'; 5 | 6 | fc = 1e3; 7 | x = sin(2*pi*t); 8 | 9 | ydouble = ammod(x,fc,fs); 10 | ysingle = ssbmod(x,fc,fs); 11 | 12 | sa = dsp.SpectrumAnalyzer('SampleRate',fs, ... 13 | 'PlotAsTwoSidedSpectrum',false, ... 14 | 'YLimits',[-60 40]); 15 | step(sa,ydouble) 16 | 17 | step(sa,ysingle) -------------------------------------------------------------------------------- /rayleigh channel simulation/FSK.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | close all; 4 | %% 参数设置 5 | Modulation_Order=2; 6 | Packet_Length=64; 7 | SymbolRate=1000; 8 | SamplesPerSymbol=8; %每个符号的样点数 9 | 10 | df=400; %FSK调制相邻载波频率间隔,单位Hz 11 | fs=SamplesPerSymbol*SymbolRate; %采样率,即码率与每个码采样点的乘积 12 | 13 | SNR=10; 14 | ts=1/fs; 15 | fd=0; 16 | k=3; 17 | tau=[0 1 2]*ts; %每条径的时延 18 | pdb=[2 1 0]; %每条径的增益 19 | 20 | 21 | %% 调制器、解调器、莱斯信道设置 22 | %默认连续相位、整数输入的FSK调制器 23 | H_Mod = comm.FSKModulator(... 24 | 'ModulationOrder',Modulation_Order,... 25 | 'SymbolRate',1000 ,... 26 | 'SamplesPerSymbol',8, ... 27 | 'FrequencySeparation',df); 28 | 29 | % 解调器 30 | H_Demod = comm.FSKDemodulator(... 31 | 'ModulationOrder',Modulation_Order,... 32 | 'SymbolRate',1000 ,... 33 | 'SamplesPerSymbol',8, ... 34 | 'FrequencySeparation',df); 35 | 36 | % rician信道 37 | chan_Rici = ricianchan(ts,fd,k,tau,pdb); 38 | 39 | %% 调制 过信道 加噪声 解调 40 | data_Original = randi([0 Modulation_Order-1],Packet_Length,1); 41 | data_AfterFSK=step(H_Mod,data_Original); 42 | data_AfterRici=filter(chan_Rici,data_AfterFSK); 43 | data_AfterAwgn=awgn(data_AfterRici,SNR,'measured'); 44 | data_AfterDeFSK=step(H_Demod,data_AfterAwgn); 45 | 46 | %% 画图 47 | 48 | % FSK调制后的信号为实际信号的等效低通信号,即复数信号,看波形时只要看实部即可。 49 | figure(1) 50 | plot(real(data_AfterFSK),'r*-'); 51 | grid on; 52 | 53 | figure(2) 54 | plot(data_Original,'r*-'); 55 | hold on 56 | plot(data_AfterDeFSK,'go-'); -------------------------------------------------------------------------------- /rayleigh channel simulation/SNR10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/SNR10.mat -------------------------------------------------------------------------------- /rayleigh channel simulation/SNR8_RSS_scheme1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/SNR8_RSS_scheme1.mat -------------------------------------------------------------------------------- /rayleigh channel simulation/c1D_tf_801.m: -------------------------------------------------------------------------------- 1 | % 2x1D Wiener CE for OFDM systems 2 | % first 1D in time domain, followed by 1D in frequency domain 3 | % 4 | % i) Channel: exponentially decaying profile, Jakes' Doppler spectrum 5 | % ii) 802.11a parameters 6 | % iii)802.11a pilot spacing (short + long + pilot-tones, Nf=12,Nt=1), 7 | % with rectangular (as the standard) or diagonal pattern. 8 | % 9 | % i) After time domain interpolation, more interploated channel coefficients should 10 | % be used in freq. domain interpolation. (changed from Ufuk's code.) 11 | % ii) For the pilots pattern of 802.11a, freq. first is not an appropriate order 12 | % since N_f = 12 is larger than the rule-of-thumb Nyquist rate. So OneD_ft.m 13 | % is NOT implemented FOR 802.11a parameters. 14 | % 15 | % Note: coded for OFDM trained CE survey project 16 | 17 | clear all; 18 | 19 | im=sqrt(-1); 20 | randn('seed',sum(100*clock)); 21 | rand('seed',sum(100*clock)); 22 | 23 | L=64; % OFDM block length 24 | L2=52; % modulated OFDM carriers 25 | C=16; % length of cyclic prefix 26 | 27 | % system sampling frequency 28 | fs = 20e+6; 29 | 30 | % fcar: carrier separation in Hz 31 | fcar=fs/L; % subcarrier spacing in Hz 32 | 33 | % Assume portable receivers with moderate doppler 34 | % random Doppler frequency (Hz) 35 | % Doppler from the following values: 0Hz, 5Hz, 25Hz, 50Hz, or 100Hz 36 | fDmax = 0; 37 | 38 | % pilot pattern selection: 39 | % 0: rect. grid (as the standard) 40 | % 1: diagonal distri 41 | % xoooooo 42 | % oxooooo 43 | % ooxoooo 44 | % xooxooo 45 | % oxooxoo 46 | % ooxooxo 47 | pilotpattern = 1; 48 | 49 | % let tau_max = 5 * tau_rms; 50 | tau_rms = 50e-9; 51 | tau_max = 5 * tau_rms; 52 | nprofile = 1; 53 | 54 | Ts=4e-6; %ofdm block duration 55 | % It seems the above Ts includes CP,(64+16)/20e6, since C=16 the length of cyclic prefix 56 | 57 | % Decision on number of taps used in Wiener filter: 58 | % Notice 10 taps used in wiener2d.m, i.e., mtap = 10. We use 5 taps first 59 | % in time domain (for this case, assumer higher correlation in the time 60 | % domain; frequency domain pilots are insufficient anyway) and then another 61 | % 5 in frequency domain. 62 | % The matrices involved will be smaller, and thus the code will run 63 | % approximately 400 % faster. 64 | 65 | %total number of taps in frequency domain 66 | ftap=10; 67 | % 10 points will participate in the calculation 68 | %total number of taps in time domain 69 | ttap=10; 70 | 71 | iswitch=3; 72 | % Assume we use weighted distances such as 73 | % |k-k'|f_{dmax}T_{s}+ |l-l'| tau_{max} \Delta F 74 | 75 | 76 | % OFDM symbol/block duration 77 | T_symbol=(L+C)/fs; 78 | fmaxt=fDmax*T_symbol; 79 | % normalization 80 | taumaxf=tau_max*fcar; 81 | 82 | SNR=0:10:40; 83 | 84 | % pilot tones 85 | stones=[-21 -7 7 21]; 86 | ftones=stones+32; 87 | 88 | % short training symbols 89 | sshort=[ -24 -20 -16 -12 -8 -4 4 8 12 16 20 24 ]; 90 | fshort=sshort+32; 91 | 92 | % long training symbols 93 | slong=[-25:1:26]; 94 | flong=slong+32; 95 | 96 | Nshort=length(fshort); 97 | Ntones=length(ftones); 98 | Nlong=length(flong); 99 | 100 | % OFDM symbols in a packet (K) 101 | Kvec=[10 20 50 100 200]; 102 | Kvec = [59]; 103 | lKvec=length(Kvec); 104 | 105 | % MC runs, let's set it to 1 for speed. 106 | mcrun=10; 107 | 108 | %mcsw = 0; % switch used in displaying progress 109 | 110 | for Krun=1:lKvec 111 | K=Kvec(Krun); 112 | 113 | npilot=2*12+2*52+(K-4)*4; 114 | coord_pilot=zeros(npilot,2); 115 | 116 | % compute pilot symbols ("rect grid") 117 | % 802.11a pilot pattern can be calculated in the following way 118 | j=0; 119 | for k=1:K 120 | if k < 3 121 | for l=1:Nshort 122 | j=j+1; 123 | coord_pilot(j,:)=[fshort(l) k]; 124 | end 125 | elseif k < 5 126 | for l=1:Nlong 127 | j=j+1; 128 | coord_pilot(j,:)=[flong(l) k]; 129 | end 130 | else 131 | for l=1:Ntones 132 | j=j+1; 133 | if (pilotpattern == 0) 134 | % rect. grid (as the standard) 135 | coord_pilot(j,:)=[ftones(l) k]; 136 | elseif (pilotpattern == 1) 137 | % diag. pattern 1 138 | coord_pilot(j,:)=[mod(k-1+ftones(l)-7,L-12)+7 k]; 139 | end 140 | end 141 | end 142 | end 143 | 144 | 145 | % Plot pilot positions to verify 146 | % plot(coord_pilot(:,1),coord_pilot(:,2),'x'); 147 | % xlabel('OFDM symbol (frequency) index'); ylabel('subcarrier (time) index'); 148 | 149 | % the vector of all pilots 150 | Ntap = j; % Ques? 151 | % Ntap=348=6*58, 6 is along frequency, 58 is along time 152 | 153 | % 4/5/02 "Ufuk's" comments: j from previous stage is the total number of pilot tones 154 | 155 | mse=zeros(length(SNR),1); % MSE vector 156 | %mse_th= zeros(length(SNR),1); 157 | 158 | for drun=1:mcrun 159 | % Channel H(L,K) 160 | fprintf('*'); 161 | H = rayleigh(fmaxt,fDmax,fcar,tau_rms,nprofile,K,L).'; 162 | % H: complex output vector (channel frequency responses) 163 | % L: the number of carriers, K: the number of symbols 164 | 165 | for SNRcount=1:length(SNR) 166 | N0_Eb=10^(-SNR(SNRcount)/20); 167 | sigma=sqrt(N0_Eb/2); 168 | noise=(randn(L,K)+im*randn(L,K)); 169 | noises=sigma*noise; 170 | R=H+noises; 171 | 172 | % Channel est 173 | H_hat=zeros(L,K); 174 | H_t=zeros(L,K); 175 | 176 | for l=7:58 177 | % the valid frequency pins are between 7--58, the other 12 178 | % are zero 179 | for k=1:K 180 | % Search ttap nearest pilot positions in TIME domain 181 | % In time domain filtering, there may only be two pilots 182 | % at a given frequency in this means 183 | numlarge=1e6; 184 | rat=1e6*ones(Ntap,1); 185 | 186 | for j=1:Ntap 187 | templ = (l-coord_pilot(j,1)); 188 | % l is freq direction, k is time direction, 189 | % coord_pilot 1st column is frequency, 2nd column 190 | % is time 191 | %only time direction first 192 | tempk=(k-coord_pilot(j,2)); 193 | 194 | if (templ==0) % count only the pilots @ the same sub carrier 195 | if (iswitch == 0) %compute Euclidean distances 196 | % iswitch is the norm definition of 197 | % Euclidean distances 198 | dist= tempk^2; 199 | elseif (iswitch == 1) %absolute distance 200 | dist=abs(tempk); 201 | elseif (iswitch == 2) %compute weighted distances I 202 | dist_t=abs(tempk); 203 | rho_t= rho_jakes(dist_t,fmaxt,nprofile); 204 | dist=1-abs(rho_t); 205 | elseif (iswitch == 3) %compute weighted distances II 206 | dist=abs(tempk)*fmaxt; 207 | else 208 | error( 'switch > 3 not implemented') 209 | end 210 | 211 | rat(j)=dist; 212 | end 213 | end 214 | 215 | [asortt, rbt]=sort(rat); 216 | rbval=(asortt< 1e5); 217 | t2tap=min(sum(rbval),ttap); 218 | yt=zeros(t2tap,1); 219 | coord_yt=zeros(t2tap,2); 220 | 221 | for j=1:t2tap 222 | temp = [coord_pilot(rbt(j),1) coord_pilot(rbt(j),2)]; 223 | coord_yt(j,:)=temp; 224 | yt(j,:)=R(temp(1),temp(2)); 225 | end 226 | 227 | % Find autocorrelation of pilots 228 | thetat=zeros(t2tap,1); 229 | Phit=zeros(t2tap,t2tap); 230 | 231 | for i=1:t2tap 232 | for j=1:t2tap % find correlation of pilots 233 | distemp=coord_yt(i,:)- coord_yt(j,:); 234 | dist_t=distemp(:,2); 235 | Phit(i,j) = ray_jakes(dist_t,fmaxt,nprofile);; 236 | end 237 | 238 | %find correlation of pilots with data 239 | distth=coord_yt(i,2)-k; 240 | thetat(i) = ray_jakes(distth,fmaxt,nprofile); 241 | end 242 | 243 | % The pilots will have noise on them so include. 244 | Phit=Phit+N0_Eb*eye(t2tap); 245 | Wot=thetat'*inv(Phit); 246 | H_t(l,k)=Wot*yt; 247 | end 248 | end 249 | 250 | % now start freq. domain interpolation 251 | 252 | % When doing freq. domain interp., pilots include both the real pilots and those interp. from 253 | % time domain. Coord_newpilot keeps coordinates of all those references (same for all k index - 254 | % projection to l) 255 | temp = coord_pilot(:,1); 256 | %tempnot = [1:6 59:64]; 257 | coord_newpilot = []; 258 | for tmpind=1:length(temp) 259 | TF = ismember(temp(tmpind),coord_newpilot); 260 | if (TF == 0) 261 | coord_newpilot = [coord_newpilot temp(tmpind)]; 262 | end 263 | end 264 | newpil_len = length(coord_newpilot); 265 | 266 | for l=7:58 267 | for k=1:K 268 | raf=1e6*ones(newpil_len,1); 269 | for j=1:newpil_len 270 | templ= l- coord_newpilot(j); 271 | 272 | if (iswitch == 0) %compute Euclidean distances, 273 | dist= templ^2; 274 | elseif (iswitch == 1) 275 | dist=abs(templ); 276 | elseif (iswitch == 2) 277 | dist_f=abs(templ); 278 | rho_f = rho_exp(dist_f,taumaxf,tau_rms,nprofile); 279 | dist=1-abs(rho_f); 280 | elseif (iswitch == 3) 281 | dist= abs(templ)*taumaxf; 282 | else 283 | error( 'switch > 3 not implemented'); 284 | end 285 | 286 | raf(j)=dist; 287 | %end for iswitch loop 288 | end 289 | 290 | [asortf, rbf]=sort(raf); 291 | rbval=(asortf< 1e5); 292 | f2tap=min(sum(rbval),ftap); 293 | yk=zeros(f2tap,1); 294 | coord_yk=zeros(f2tap,2); 295 | 296 | for j=1:f2tap 297 | temp = coord_newpilot(rbf(j)); 298 | coord_yk(j,:)=[temp k]; 299 | %Instead of using the data use the time filtered estimates 300 | yk(j,:)=H_t(temp,k); 301 | %end for yk loop 302 | end 303 | 304 | thetaf=zeros(f2tap,1); 305 | Phif=zeros(f2tap,f2tap); 306 | 307 | for i=1:f2tap 308 | for j=1:f2tap 309 | distemp=coord_yk(i,:)- coord_yk(j,:); 310 | dist_f=distemp(:,1); 311 | Phif(i,j) = ray_exp(dist_f,taumaxf,tau_rms,nprofile); 312 | end 313 | 314 | disfth=coord_yk(i,1)-l; 315 | thetaf(i)=ray_exp(disfth,taumaxf,tau_rms,nprofile); 316 | end 317 | 318 | % The pilots will have noise on them so include. 319 | Phif=Phif+N0_Eb*eye(f2tap); 320 | 321 | Wof=thetaf'*inv(Phif); 322 | H_hat(l,k)=Wof*yk; 323 | end 324 | end 325 | 326 | for k=1:K 327 | err=H_hat(7:58,k)-H(7:58,k); 328 | temper=(norm(err,'fro')/norm(H(:,k),'fro'))^2; % normalized MSE 329 | mse(SNRcount)=mse(SNRcount)+temper; 330 | end 331 | 332 | %end for SNR loop 333 | end 334 | 335 | %end for Drunloop (mcrun times) 336 | 337 | end 338 | 339 | fprintf('\n'); 340 | mse=mse/(L2*K*mcrun); 341 | %mse_th=mse_th/(L2*K*mcrun); 342 | 343 | %end for K loop 344 | end 345 | 346 | figure(1); 347 | %semilogy(SNR,mse,'-*', SNR, mse_th, '-.x'); 348 | semilogy(SNR,mse,'-*'); 349 | %legend('MSE','MSE theory'); 350 | 351 | xlabel('SNR (dB)'); 352 | ylabel('MSE'); 353 | grid; 354 | 355 | %title('Wiener 2D Estimator: MSE vs. SNR'); 356 | -------------------------------------------------------------------------------- /rayleigh channel simulation/multi_fading_channel.m: -------------------------------------------------------------------------------- 1 | 2 | %% Multipath Fading Channel 3 | % 该例子是展示如何使用Rayleigh和Rician多径衰减信道模型,以及其内嵌可视化模型。 4 | % 对于仿真实际无线通信场景,Rayleigh和Rician衰减信道模型是非常有用的衰减现象。它们 5 | % 包括多径散射效应,时间弥散,相对运动引起的多普勒频移等现象。 6 | 7 | % 使用衰减信号模型来处理信号包括以下几步: 8 | % 1.Create a channel System object that describes the channel that you want to use. A channel object is a 9 | % type of MATLAB® variable that contains information about the channel, such as the maximum Doppler shift. 10 | % 2.Adjust properties of the System object, if necessary, to tailor it to your needs. 11 | % For example, you can change the path delays or average path gains. 12 | % 3.Apply the channel System object to your signal using the step method, which generates 13 | % random discrete path gains and filters the input signal. 14 | 15 | 16 | %% Initialization 17 | % The following variables control both the Rayleigh and Rician channel 18 | % objects. By default, the channel is modeled as four fading paths, each 19 | % representing a cluster of multipath components received at around the 20 | % same delay. 21 | 22 | % 初始化,四条多径,每条频移和时间延迟 23 | sampleRate500KHz = 500e3; % Sample rate of 500K Hz 24 | sampleRate20KHz = 20e3; % Sample rate of 20K Hz 25 | maxDopplerShift = 200; % Maximum Doppler shift of diffuse components (Hz) 26 | delayVector = (0:5:15)*1e-6; % Discrete delays of four-path channel (s) 27 | gainVector = [0 -3 -6 -9]; % Average path gains (dB) 28 | 29 | %% 30 | % The maximum Doppler shift is computed as v*f/c, where v is the mobile 31 | % speed, f is the carrier frequency, and c is the speed of light. For 32 | % example, a maximum Doppler shift of 200 Hz (as above) corresponds to a 33 | % mobile speed of 65 mph (30 m/s) and a carrier frequency of 2 GHz. 34 | % 35 | % By convention, the delay of the first path is typically set to zero. For 36 | % subsequent paths, a 1 microsecond delay corresponds to a 300 m difference 37 | % in path length. In some outdoor multipath environments, reflected paths 38 | % can be up to several kilometers longer than the shortest path. With the 39 | % path delays specified above, the last path is 4.5 km longer than the 40 | % shortest path, and thus arrives 15 microseconds later. 41 | % 42 | % Together, the path delays and path gains specify the channel's average 43 | % delay profile. Typically, the average path gains decay exponentially 44 | % with delay (i.e., the dB values decay linearly), but the specific delay 45 | % profile depends on the propagation environment. In the delay profile 46 | % specified above, we assume a 3 dB decrease in average power for every 5 47 | % microseconds of path delay. 48 | % 49 | % The following variables control the Rician channel System object. The 50 | % Doppler shift of the specular component is typically smaller than the 51 | % maximum Doppler shift (above) and depends on the mobile's direction of 52 | % travel relative to the direction of the specular component. The K-factor 53 | % specifies the linear ratio of average received power from the specular 54 | % component relative to that of the associated diffuse components. 55 | 56 | 57 | KFactor = 10; % Linear ratio of specular power to diffuse power 58 | specDopplerShift = 100; % Doppler shift of specular component (Hz) 59 | 60 | %% Creating Channel System Objects 61 | % With the parameters specified above, we can now create the 62 | % || and 63 | % || System objects. We 64 | % configure the objects to use their self-contained random stream with a 65 | % specified seed for path gain generation. 66 | 67 | % Configure a Rayleigh channel object 68 | rayChan = comm.RayleighChannel( ... 69 | 'SampleRate', sampleRate500KHz, ... 70 | 'PathDelays', delayVector, ... 71 | 'AveragePathGains', gainVector, ... 72 | 'MaximumDopplerShift', maxDopplerShift, ... 73 | 'RandomStream', 'mt19937ar with seed', ... 74 | 'Seed', 10, ... 75 | 'PathGainsOutputPort', true); 76 | 77 | % Configure a Rician channel object 78 | ricChan = comm.RicianChannel( ... 79 | 'SampleRate', sampleRate500KHz, ... 80 | 'PathDelays', delayVector, ... 81 | 'AveragePathGains', gainVector, ... 82 | 'KFactor', KFactor, ... 83 | 'DirectPathDopplerShift', specDopplerShift, ... 84 | 'MaximumDopplerShift', maxDopplerShift, ... 85 | 'RandomStream', 'mt19937ar with seed', ... 86 | 'Seed', 100, ... 87 | 'PathGainsOutputPort', true); 88 | 89 | %% Modulation and Channel Filtering 90 | % Create a || System object to 91 | % modulate the channel data, which has been generated using the RANDI 92 | % function. Note that in the code below a 'frame' refers to a vector of 93 | % information bits. A phase offset of pi/4 is used for this example. 94 | qpskMod = comm.QPSKModulator( ... 95 | 'BitInput', true, ... 96 | 'PhaseOffset', pi/4); 97 | 98 | 99 | % Number of bits transmitted per frame is set to be 1000. For QPSK 100 | % modulation, this corresponds to 500 symbols per frame. 101 | bitsPerFrame = 1000; 102 | msg = randi([0 1],bitsPerFrame,1); 103 | 104 | % Modulate data for transmission over channel 105 | modSignal = qpskMod(msg); 106 | 107 | % Apply Rayleigh or Rician channel object on the modulated data 108 | rayChan(modSignal); 109 | ricChan(modSignal); 110 | 111 | %% Visualization 112 | % The fading channel System objects have built-in visualization to show the 113 | % channel impulse response, frequency response, or Doppler spectrum from 114 | % the |step| method. To invoke it, set the |Visualization| property to its 115 | % desired value before calling the |step| method. Release the Rayleigh and 116 | % Rician channel System objects now so that we can change their property 117 | % values. 118 | 119 | release(rayChan); 120 | release(ricChan); 121 | 122 | %% Wideband or Frequency-Selective Fading 123 | % Setting the |Visualization| property to |'Impulse response'| shows the 124 | % bandlimited impulse response (yellow circles). The visualization also 125 | % shows the delays and magnitudes of the underlying fading path gains (pink 126 | % stembars) clustered around the peak of the impulse response. Note that 127 | % the path gains do not equal the |AveragePathGains| property value because 128 | % the Doppler effect causes the gains to fluctuate over time. 129 | % 130 | % Similarly, setting the |Visualization| property to |'Frequency response'| 131 | % shows the frequency response (DFT transformation) of the impulses. You 132 | % can also set |Visualization| to |'Impulse and frequency responses'| to 133 | % display both impulse and frequency responses side by side. . 134 | % 135 | % You can control the percentage of the input samples to be visualized by 136 | % changing the |SamplesToDisplay| property. In general, the smaller the 137 | % percentage, the faster the simulation runs. Once the visualization figure 138 | % opens up, click the |Playback| button and turn off the "Reduce Updates to 139 | % Improve Performance" or "Reduce Plot Rate to Improve Performance" option 140 | % to further improve display accuracy. The option is on by default for 141 | % faster simulation. To see the channel response for every input sample, 142 | % uncheck this option and set |SamplesToDisplay| to |'100%'|. 143 | 144 | rayChan.Visualization = 'Impulse and frequency responses'; 145 | rayChan.SamplesToDisplay = '100%'; 146 | 147 | numFrames = 2; 148 | 149 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 150 | % Create random data 151 | msg = randi([0 1],bitsPerFrame,1); 152 | % Modulate data 153 | modSignal = qpskMod(msg); 154 | % Filter data through channel and show channel responses 155 | rayChan(modSignal); 156 | end 157 | 158 | %% 159 | % As you can see, the channel frequency response is not flat and may have 160 | % deep fades over the 500K Hz bandwidth. Because the power level varies 161 | % over the signal's bandwidth, it is referred to as frequency-selective 162 | % fading. 163 | % 164 | % For the same channel specification, we now display the Doppler spectrum 165 | % for its first discrete path, which is a statistical characterization of 166 | % the fading process. The System object makes periodic measurements of the 167 | % Doppler spectrum (blue stars). Over time with more samples processed by 168 | % the System object, the average of this measurement better approximates 169 | % the theoretical Doppler spectrum (yellow curve). 170 | 171 | release(rayChan); 172 | rayChan.Visualization = 'Doppler spectrum'; 173 | 174 | numFrames = 5000; 175 | 176 | for i = 1:numFrames % Display Doppler spectrum from 5000 frame transmission 177 | msg = randi([0 1],bitsPerFrame,1); 178 | modSignal = qpskMod(msg); 179 | rayChan(modSignal); 180 | end 181 | 182 | %% Narrowband or Frequency-Flat Fading 183 | % When the bandwidth is too small for the signal to resolve the individual 184 | % components, the frequency response is approximately flat because of the 185 | % minimal time dispersion caused by the multipath channel. This kind of 186 | % multipath fading is often referred to as narrowband fading, or 187 | % frequency-flat fading. 188 | % 189 | % We now reduce the signal bandwidth from 500 kb/s (250 ksym/s) to 20 kb/s 190 | % (10 ksym/s), so the channel's delay span (15 microseconds) is much 191 | % smaller than the QPSK symbol period (100 microseconds). The resultant 192 | % impulse response has very small intersymbol interference (ISI) and the 193 | % frequency response is approximately flat. 194 | 195 | release(rayChan); 196 | rayChan.Visualization = 'Impulse and frequency responses'; 197 | rayChan.SampleRate = sampleRate20KHz; 198 | rayChan.SamplesToDisplay = '25%'; % Display one of every four samples 199 | 200 | numFrames = 2; 201 | 202 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 203 | msg = randi([0 1],bitsPerFrame,1); 204 | modSignal = qpskMod(msg); 205 | rayChan(modSignal); 206 | end 207 | 208 | %% 209 | % To simplify and speed up modeling, narrowband fading channels are 210 | % typically modeled as a single-path fading channel. That is, a multipath 211 | % fading model overspecifies a narrowband fading channel. The following 212 | % settings correspond to a narrowband fading channel. Notice that the shape 213 | % of the bandlimited impulse response is flat. 214 | 215 | release(rayChan); 216 | rayChan.PathDelays = 0; % Single fading path with zero delay 217 | rayChan.AveragePathGains = 0; % Average path gain of 1 (0 dB) 218 | 219 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 220 | msg = randi([0 1],bitsPerFrame,1); 221 | modSignal = qpskMod(msg); 222 | rayChan(modSignal); 223 | end 224 | 225 | %% 226 | % The Rician fading channel System object models line-of-sight propagation 227 | % in addition to diffuse multipath scattering. This results in a smaller 228 | % variation in the magnitude of path gains. To compare the variation 229 | % between Rayleigh and Rician channels, we make use of a 230 | % || System object to view their path 231 | % gains over time. Note that the magnitude fluctuates over approximately a 232 | % 10 dB range for the Rician fading channel (blue curve), compared with 233 | % 30-40 dB for the Rayleigh fading channel (yellow curve). For the Rician 234 | % fading channel, this variation would be further reduced by increasing the 235 | % K-factor (currently set to 10). 236 | 237 | release(rayChan); 238 | rayChan.Visualization = 'Off'; % Turn off System object's visualization 239 | ricChan.Visualization = 'Off'; % Turn off System object's visualization 240 | 241 | % Same sample rate and delay profile for the Rayleigh and Rician objects 242 | ricChan.SampleRate = rayChan.SampleRate; 243 | ricChan.PathDelays = rayChan.PathDelays; 244 | ricChan.AveragePathGains = rayChan.AveragePathGains; 245 | 246 | % Configure a Time Scope System object to show path gain magnitude 247 | gainScope = dsp.TimeScope( ... 248 | 'SampleRate', rayChan.SampleRate, ... 249 | 'TimeSpan', bitsPerFrame/2/rayChan.SampleRate, ... % One frame span 250 | 'Name', 'Multipath Gain', ... 251 | 'ShowGrid', true, ... 252 | 'YLimits', [-40 10], ... 253 | 'YLabel', 'Gain (dB)'); 254 | 255 | % Compare the path gain outputs from both objects for one frame 256 | msg = randi([0 1],bitsPerFrame,1); 257 | modSignal = qpskMod(msg); 258 | [~, rayPathGain] = rayChan(modSignal); 259 | [~, ricPathGain] = ricChan(modSignal); 260 | % Form the path gains as a two-channel input to the time scope 261 | gainScope(10*log10(abs([rayPathGain, ricPathGain]).^2)); 262 | 263 | %% Fading Channel Impact on Signal Constellation 264 | % We now return to our original four-path Rayleigh fading channel. We use 265 | % a || System object to 266 | % show the impact of narrowband fading on the signal constellation. To 267 | % slow down the channel dynamics for visualization purposes, we reduce the 268 | % maximum Doppler shift to 5 Hz. Compared with the QPSK channel input 269 | % signal, you can observe signal attenuation and rotation at the channel 270 | % output, as well as some signal distortion due to the small amount of ISI 271 | % in the received signal. 272 | 273 | clear hRicChan hMultipathGain; 274 | release(rayChan); 275 | 276 | rayChan.PathDelays = delayVector; 277 | rayChan.AveragePathGains = gainVector; 278 | rayChan.MaximumDopplerShift = 5; 279 | 280 | % Configure a Constellation Diagram System object to show received signal 281 | constDiag = comm.ConstellationDiagram( ... 282 | 'Name', 'Received Signal After Rayleigh Fading'); 283 | 284 | numFrames = 16; 285 | 286 | for n = 1:numFrames 287 | msg = randi([0 1],bitsPerFrame,1); 288 | modSignal = qpskMod(msg); 289 | rayChanOut = rayChan(modSignal); 290 | % Display constellation diagram for Rayleigh channel output 291 | constDiag(rayChanOut); 292 | end 293 | 294 | %% 295 | % When we increase the signal bandwidth to 500 kb/s (250 ksym/s), we see 296 | % much greater distortion in the signal constellation. This distortion is 297 | % the ISI that comes from time dispersion of the wideband signal. The 298 | % channel's delay span (15 microseconds) is now larger than the QPSK symbol 299 | % period (4 microseconds), so the resultant bandlimited impulse response is 300 | % no longer approximately flat. 301 | 302 | release(rayChan); 303 | release(constDiag); 304 | rayChan.SampleRate = sampleRate500KHz; 305 | 306 | for n = 1:numFrames 307 | msg = randi([0 1],bitsPerFrame,1); 308 | modSignal = qpskMod(msg); 309 | rayChanOut = rayChan(modSignal); 310 | constDiag(rayChanOut); 311 | end 312 | 313 | displayEndOfDemoMessage(mfilename) 314 | -------------------------------------------------------------------------------- /rayleigh channel simulation/multi_fading_channel_wp.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | sampleRate500KHz = 500e3; % Sample rate of 500K Hz 4 | sampleRate20KHz = 20e3; % Sample rate of 20K Hz 5 | maxDopplerShift = 200; % Maximum Doppler shift of diffuse components (Hz) 6 | delayVector = (0:5:15)*1e-6; % Discrete delays of four-path channel (s) 7 | gainVector = [0 -3 -6 -9]; % Average path gains (dB) 8 | 9 | KFactor = 10; % Linear ratio of specular power to diffuse power 10 | specDopplerShift = 100; % Doppler shift of specular component (Hz) 11 | 12 | % Configure a Rayleigh channel object 13 | rayChan = comm.RayleighChannel( ... 14 | 'SampleRate', sampleRate500KHz, ... 15 | 'PathDelays', delayVector, ... 16 | 'AveragePathGains', gainVector, ... 17 | 'MaximumDopplerShift', maxDopplerShift, ... 18 | 'RandomStream', 'mt19937ar with seed', ... 19 | 'Seed', 10, ... 20 | 'PathGainsOutputPort', true); 21 | 22 | % Configure a Rician channel object 23 | ricChan = comm.RicianChannel( ... 24 | 'SampleRate', sampleRate500KHz, ... 25 | 'PathDelays', delayVector, ... 26 | 'AveragePathGains', gainVector, ... 27 | 'KFactor', KFactor, ... 28 | 'DirectPathDopplerShift', specDopplerShift, ... 29 | 'MaximumDopplerShift', maxDopplerShift, ... 30 | 'RandomStream', 'mt19937ar with seed', ... 31 | 'Seed', 100, ... 32 | 'PathGainsOutputPort', true); 33 | 34 | qpskMod = comm.QPSKModulator( ... 35 | 'BitInput', true, ... 36 | 'PhaseOffset', pi/4); 37 | 38 | % Number of bits transmitted per frame is set to be 1000. For QPSK 39 | % modulation, this corresponds to 500 symbols per frame. 40 | bitsPerFrame = 1000; 41 | msg = randi([0 1],bitsPerFrame,1); 42 | 43 | % Modulate data for transmission over channel 44 | modSignal = qpskMod(msg); 45 | 46 | % Apply Rayleigh or Rician channel object on the modulated data 47 | rayChan(modSignal); 48 | ricChan(modSignal); 49 | 50 | release(rayChan); 51 | release(ricChan); 52 | 53 | rayChan.Visualization = 'Impulse and frequency responses'; 54 | rayChan.SamplesToDisplay = '100%'; 55 | 56 | numFrames = 2; 57 | 58 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 59 | % Create random data 60 | msg = randi([0 1],bitsPerFrame,1); 61 | % Modulate data 62 | modSignal = qpskMod(msg); 63 | % Filter data through channel and show channel responses 64 | rayChan(modSignal); 65 | end 66 | 67 | 68 | release(rayChan); 69 | rayChan.Visualization = 'Doppler spectrum'; 70 | 71 | numFrames = 5000; 72 | 73 | for i = 1:numFrames % Display Doppler spectrum from 5000 frame transmission 74 | msg = randi([0 1],bitsPerFrame,1); 75 | modSignal = qpskMod(msg); 76 | rayChan(modSignal); 77 | end 78 | 79 | release(rayChan); 80 | rayChan.Visualization = 'Impulse and frequency responses'; 81 | rayChan.SampleRate = sampleRate20KHz; 82 | rayChan.SamplesToDisplay = '25%'; % Display one of every four samples 83 | 84 | numFrames = 2; 85 | 86 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 87 | msg = randi([0 1],bitsPerFrame,1); 88 | modSignal = qpskMod(msg); 89 | rayChan(modSignal); 90 | end 91 | 92 | 93 | release(rayChan); 94 | rayChan.PathDelays = 0; % Single fading path with zero delay 95 | rayChan.AveragePathGains = 0; % Average path gain of 1 (0 dB) 96 | 97 | for i = 1:numFrames % Display impulse and frequency responses for 2 frames 98 | msg = randi([0 1],bitsPerFrame,1); 99 | modSignal = qpskMod(msg); 100 | rayChan(modSignal); 101 | end 102 | 103 | release(rayChan); 104 | rayChan.Visualization = 'Off'; % Turn off System object's visualization 105 | ricChan.Visualization = 'Off'; % Turn off System object's visualization 106 | 107 | % Same sample rate and delay profile for the Rayleigh and Rician objects 108 | ricChan.SampleRate = rayChan.SampleRate; 109 | ricChan.PathDelays = rayChan.PathDelays; 110 | ricChan.AveragePathGains = rayChan.AveragePathGains; 111 | 112 | % Configure a Time Scope System object to show path gain magnitude 113 | gainScope = dsp.TimeScope( ... 114 | 'SampleRate', rayChan.SampleRate, ... 115 | 'TimeSpan', bitsPerFrame/2/rayChan.SampleRate, ... % One frame span 116 | 'Name', 'Multipath Gain', ... 117 | 'ShowGrid', true, ... 118 | 'YLimits', [-40 10], ... 119 | 'YLabel', 'Gain (dB)'); 120 | 121 | % Compare the path gain outputs from both objects for one frame 122 | msg = randi([0 1],bitsPerFrame,1); 123 | modSignal = qpskMod(msg); 124 | [~, rayPathGain] = rayChan(modSignal); 125 | [~, ricPathGain] = ricChan(modSignal); 126 | % Form the path gains as a two-channel input to the time scope 127 | gainScope(10*log10(abs([rayPathGain, ricPathGain]).^2)); 128 | 129 | clear hRicChan hMultipathGain; 130 | release(rayChan); 131 | 132 | rayChan.PathDelays = delayVector; 133 | rayChan.AveragePathGains = gainVector; 134 | rayChan.MaximumDopplerShift = 5; 135 | 136 | % Configure a Constellation Diagram System object to show received signal 137 | constDiag = comm.ConstellationDiagram( ... 138 | 'Name', 'Received Signal After Rayleigh Fading'); 139 | 140 | numFrames = 16; 141 | 142 | for n = 1:numFrames 143 | msg = randi([0 1],bitsPerFrame,1); 144 | modSignal = qpskMod(msg); 145 | rayChanOut = rayChan(modSignal); 146 | % Display constellation diagram for Rayleigh channel output 147 | constDiag(rayChanOut); 148 | end 149 | 150 | 151 | release(rayChan); 152 | release(constDiag); 153 | rayChan.SampleRate = sampleRate500KHz; 154 | 155 | for n = 1:numFrames 156 | msg = randi([0 1],bitsPerFrame,1); 157 | modSignal = qpskMod(msg); 158 | rayChanOut = rayChan(modSignal); 159 | constDiag(rayChanOut); 160 | end -------------------------------------------------------------------------------- /rayleigh channel simulation/multi_sin_power.m: -------------------------------------------------------------------------------- 1 | %% Theoretical Power of Multiple Sinusoids 2 | 3 | clc; 4 | clear; 5 | close all; 6 | Fs = 1024; 7 | t = 0:1/Fs:1-(1/Fs); 8 | 9 | A0 = 1.5; % Vpeak, DC 10 | A1 = 4; 11 | A2 =3; 12 | 13 | F1 = 100; 14 | F2 = 200; 15 | 16 | x = A0 + A1*sin(2*pi*F1*t) + A2*sin(2*pi*F2*t); 17 | 18 | % let's look at a portion of our signal 19 | figure(1); 20 | idx = 1:200; 21 | plot(t(idx),x(idx)); 22 | grid on; 23 | ylabel('Amplitude'); 24 | xlabel('Time(sec)'); 25 | 26 | hgcf = gcf; 27 | hgcf.Color = [1 1 1]; 28 | 29 | %% The theoretical average power (mean-square) of each complex sinusoid is A^2/4 30 | %% the theoretical average power of each complex sinusoid 31 | power_theoretical = A0^2 + (A1^2/4)*2 + (A2^2/4)*2 32 | 33 | figure(2); 34 | % use the periodogram function to calculate and plot the power spectrum of the signal. 35 | periodogram(x, hamming(length(x)),[],Fs,'centered','power'); 36 | 37 | % estimating the signal's total average power by "integrating" under the PSD curve we get: 38 | % 方括号中,前者是功率,后者是频率,构成功率谱 39 | [Pxx, F] = periodogram(x, hamming(length(x)), [], Fs, 'centered', 'psd'); 40 | 41 | power_freqdomain = bandpower(Pxx,F,'psd') 42 | 43 | power_timedomain = sum(abs(x).^2)/length(x) 44 | 45 | %% Relationship between Power Spectrum, Power Spectral Density and ENBW 46 | Pxx = periodogram(x, hamming(length(x)), [], Fs, 'centered', 'psd'); 47 | Sxx = periodogram(x, hamming(length(x)), [], Fs, 'centered', 'power'); 48 | 49 | plot(F, Sxx ./ Pxx) 50 | grid on 51 | axis tight 52 | xlabel('Frequency (Hz)') 53 | title('Ratio between Power Spectrum and Power Spectral Density') 54 | 55 | ratio = mean(Sxx ./ Pxx) 56 | 57 | bw = enbw(hamming(length(x)),Fs); 58 | 59 | %% Enhanced Power Measurements Using Reassigned Periodogram 60 | %% In the previous sections, power was measured from one or multiple 61 | %% sinusoids having a frequency that coincided with a bin. Peak power 62 | %% estimates are usually less accurate when the signal frequency is out 63 | %% of bin. To see this effect, create a sinusoid with a non-integer number 64 | %% of cycles over a one second period. 65 | 66 | 67 | Fs = 1024; 68 | t = 0:1/Fs:1-(1/Fs); 69 | A = 1; 70 | F = 20.4; 71 | x = A*sin(2*pi*F*t); 72 | NFFT = length(x); 73 | power_theoretical = 10*log10((A^2/4)*2); 74 | 75 | % Create a Hamming window and a flat top window. 76 | w1 = hamming(length(x)); 77 | w2 = flattopwin(length(x)); 78 | 79 | % Compute the periodogram of x using the Hamming window. Zoom in on the peak. 80 | h1 = figure; 81 | hold on 82 | stem(F,power_theoretical,'BaseValue',-50); 83 | [Pxx1,f1] = periodogram(x, w1, NFFT, Fs, 'power'); 84 | plot(f1,10*log10(Pxx1)) 85 | axis([0 40 -45 0]) 86 | legend('Theoretical','Periodogram') 87 | xlabel('Frequency (Hz)') 88 | ylabel('Power (dB)') 89 | title('Periodogram Power Spectrum Estimate') 90 | grid on 91 | 92 | % 取最大值 93 | [Pmax,imax] = max(Pxx1); 94 | dPmax_w1 = 10*log10(Pmax) - power_theoretical 95 | 96 | % 最大值与中心频率的偏差 97 | dFreq = f1(imax) - F 98 | 99 | %% Reduce Amplitude Error with Zero-Padding 100 | %% To see why this is happening, compute the periodogram using a larger number of FFT bins. 101 | figure 102 | hold on 103 | periodogram(x, w1, 100*NFFT, Fs, 'power') 104 | ax = gca; 105 | ax.ColorOrderIndex = 2; 106 | plot(f1,10*log10(Pxx1),'+') 107 | stem(F,power_theoretical,'BaseValue',-50) 108 | axis([0 40 -40 0]) 109 | legend('NFFT = 1024','NFFT = 102400','Theoretical Peak') 110 | 111 | 112 | figure(h1) 113 | [Pxx,F1] = periodogram(x, w2, NFFT, Fs, 'power'); 114 | plot(F1,10*log10(Pxx)) 115 | legend('Theoretical','Hamming','Flat Top') 116 | 117 | % 对比三种数值,其中两个已经重合,一模一样 118 | [RPxx1,~,~,Fc1] = periodogram(x, w1, NFFT, Fs, 'power','reassigned'); 119 | [RPxx2,~,~,Fc2] = periodogram(x, w2, NFFT, Fs, 'power','reassigned'); 120 | figure 121 | hold on 122 | stem(F,power_theoretical,'BaseValue',-40) 123 | stem(Fc1,10*log10(RPxx1),'BaseValue',-50) 124 | stem(Fc2,10*log10(RPxx2),'BaseValue',-50) 125 | legend('Theoretical','Hamming Reassignment','Flattop Reassignment') 126 | xlabel('Frequency (Hz)') 127 | ylabel('Power (dB)') 128 | title('Periodogram Power Spectrum Estimate') 129 | axis([19.5 21 -4 -2]) 130 | grid on 131 | 132 | 133 | [RPxx1max,imax1] = max(RPxx1); 134 | [RPxx2max,imax2] = max(RPxx2); 135 | dPmax_reassign_w1 = 10*log10(RPxx1max) - power_theoretical 136 | 137 | dPmax_reassign_w2 = 10*log10(RPxx2max) - power_theoretical 138 | 139 | Fc1(imax1)-F 140 | 141 | Fc2(imax2)-F -------------------------------------------------------------------------------- /rayleigh channel simulation/multipath_path_channel.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/multipath_path_channel.slx -------------------------------------------------------------------------------- /rayleigh channel simulation/ofdm_fading.m: -------------------------------------------------------------------------------- 1 | % system.m 2 | % 主程序 3 | 4 | %% 仿真信号在室内,经过大尺度和小尺度衰落后的OFDM调制 5 | 6 | clear all 7 | clc 8 | t0=clock; 9 | format long 10 | cp_length=16;%cp长度为16 11 | N_carrier=64;%802.11a OFDM子载波个数64 12 | bandwidth=17000000;%系统带宽为17MHz 13 | t_interval=(1/bandwidth)*N_carrier/(cp_length+N_carrier);%采样间隔64/70us,加上循环前缀后,采样率增加 14 | delta_f=bandwidth/N_carrier;%Hz 15 | sendpower=800;%mW 16 | d= 10; %传输距离m 17 | w= [0] ; %穿过的墙壁损耗列向量db 18 | f= [0] ; %穿过的地板损耗列向量db 19 | SNR_dB=[0 4 8 12 16 20 24 28 32];%Eb/N0 20 | SJR_dB=[0]; 21 | row_num=length(SNR_dB); 22 | ber_snr_persjr_qpsk=zeros(row_num,length(SJR_dB));%最终给出各种SJR下误码率随SNR变化的曲线 23 | ber_snr_persjr_16qam=zeros(row_num,length(SJR_dB)); 24 | counter_d=1000000;%各loop信道抽样跳动间隔 25 | no=[25,25,25,25,25,25]; 26 | for jj=1:length(SJR_dB)%每个SJR得到一条曲线 27 | sjr=10^(SJR_dB(jj)/10); 28 | for i=1:length(SNR_dB)%每个SNR点上仿真若干次 29 | error_bit=0;%错误比特数统计 30 | total_bit_num=0;%发送总比特数统计 31 | error_bit16=0;%错误比特数统计 32 | total_bit_num16=0;%发送总比特数统计 33 | loop_num=5; %共仿真5次 34 | for l=1:loop_num 35 | ofdm_symbol_num=12;%每次仿真产生200个ofdm符号,则每次仿真共有200×64个星座映射符号;QPSK调制下,1个星座映射符号包含2个bit 36 | map_flag=4; 37 | code_rate=1/2; 38 | bit_source= randn(1,N_carrier*ofdm_symbol_num*map_flag) > 0; 39 | [nbit,mbit]=size(bit_source); 40 | total_bit_num=total_bit_num+nbit*mbit; 41 | %以下为发送端卷积码编码和交织操作 42 | % Convolutional encoding 43 | coded_bit_stream = tx_conv_encoder(bit_source); 44 | tx_bits = tx_puncture(coded_bit_stream,code_rate); 45 | rdy_to_mod_bits = tx_make_int_num_ofdm_syms(tx_bits,N_carrier,map_flag); 46 | rdy_to_mod_bits1 =tx_interleaver(rdy_to_mod_bits,N_carrier,map_flag); 47 | rdy_to_mod_bits2 = reshape(rdy_to_mod_bits1,N_carrier*map_flag,length(rdy_to_mod_bits1)/(N_carrier*map_flag));%串行比特流转变成比特矩阵 48 | map_out=map_module(rdy_to_mod_bits2,map_flag); 49 | ofdm_modulation_out=sqrt(N_carrier)*ifft(map_out,N_carrier);%作64点逆FFT运算,完成ofdm调制,前面乘系数sqtr(64)是为了保持ifft前后的符号能量不变 50 | ofdm_cp_out=insert_cp(ofdm_modulation_out,cp_length);%插入循环前缀 51 | snr=10^(SNR_dB(i)/10); 52 | [nnl,mml]=size(ofdm_cp_out); 53 | 54 | %*******************大尺度衰落***********************% 55 | receivepower=bigfade(sendpower,d,w,f); 56 | sgma=sqrt(receivepower*t_interval/(2*snr)/map_flag); 57 | 58 | %************** 以下过程为ofdm符号通过频率选择性多径信道********% 59 | num=6; 60 | %假设功率延迟谱服从负指数分布~exp(-t/trms),trms=(1/4)*cp时长; 61 | %t在0~cp时长上均匀分布 62 | %若cp时长为16e-6s,可以取5径延迟如下 63 | delay=[0 5e-8 11e-8 17e-8 29e-8 31e-8 ]; 64 | trms=1.5e-6; 65 | var_pow=[0 -3 -10 -18 -26 -32];%各径功率衰减,以dB形式给出 66 | fd=50;%最大doppler频率为50Hz 67 | counter_begin=(l-1+1000000)*5*counter_d; 68 | %信道采样点数,每个调制符号采一个点 69 | ofdm_cp_out1=ofdm_cp_out*sqrt(receivepower*t_interval); 70 | [passchan_ofdm_symbol,Hk]=multipath_chann(ofdm_cp_out1,num,var_pow,delay,fd,t_interval,counter_begin,counter_d,cp_length,no);%小尺度 71 | cutcp_ofdm_symbol1=cut_cp(passchan_ofdm_symbol,cp_length); 72 | ofdm_demodulation_out1=fft(cutcp_ofdm_symbol1,N_carrier)/sqrt(N_carrier); 73 | HHk=ofdm_demodulation_out1./map_out; 74 | %******** 以上过程为ofdm符号通过频率选择性多径信道******** 75 | 76 | %******** 以下过程为ofdm符号加高斯白噪声 ************** 77 | passnoise_ofdm_symbol=add_noise(sgma,passchan_ofdm_symbol);%加入随机高斯白噪声,receive_ofdm_symbol为最终接收机收到的ofdm符号块 78 | 79 | cutcp_ofdm_symbol=cut_cp(passnoise_ofdm_symbol,cp_length);%去除循环前缀 80 | ofdm_demodulation_out=fft(cutcp_ofdm_symbol,N_carrier)/sqrt(N_carrier);%作128点FFT运算,完成ofdm解调 81 | ofdm_demodulation_out=ofdm_demodulation_out./HHk; 82 | receive_sig=de_map_module(ofdm_demodulation_out,map_flag);%解映射 83 | %以下为接收端解交织和卷积码译码操作 84 | deint_bits = rx_deinterleave(receive_sig,N_carrier,map_flag); 85 | depunc_bits = rx_depuncture(deint_bits,code_rate); 86 | viterbi_input = depunc_bits(1:(N_carrier*ofdm_symbol_num*map_flag+6)*2); 87 | % Vitervi decoding 88 | data_bits = rx_viterbi_decode(viterbi_input); 89 | receive_bit_sig=data_bits(1:N_carrier*ofdm_symbol_num*map_flag); 90 | %以下过程统计接收信号中的错误比特数 91 | err_num=error_count(bit_source,receive_bit_sig); 92 | error_bit=error_bit+err_num; 93 | fprintf('error_bit is %d\n',error_bit); 94 | end 95 | % %计算各种信噪比下的误比特率 96 | ber_snr_persjr_qpsk(i,jj)=error_bit/total_bit_num; 97 | fprintf('ber_snr_persjr_qpsk is %f\n',ber_snr_persjr_qpsk(i,jj)); 98 | end 99 | end 100 | elapse_time=etime(clock,t0); 101 | semilogy(SNR_dB,ber_snr_persjr_qpsk); 102 | 103 | 104 | % bigfade.m 105 | % 大尺度衰落 106 | % Generate bigscale fading 107 | function[receivepower]=bigfade(sendpower,d,w,f) 108 | 109 | %****************** variables ********************* 110 | L= 61.6 ; %第一米路径损耗db,2.4G时为40 111 | n=4; %路径损耗指数 112 | %************************************************** 113 | 114 | Lptco=L+10*n*log10(d)+sum(w)+sum(f); 115 | s=10^(-Lptco/10); 116 | receivepower=s*sendpower; 117 | %******************** end of file ***************** 118 | 119 | 120 | 121 | % multipath_chann.m 122 | function [output_sig,Hk]=multipath_chann(input_sig,num,var_pow,delay,fd,t_interval,counter_begin,counter,cp_n,no) 123 | %input_sig输入信号矩阵,加了cp后的信号,大小为NL×(子载波个数+cp长度lp); 124 | %num多径数; 125 | %var_pow各径相对主径的平均功率,单位dB; 126 | %delay各径延时,单位s; 127 | %fd最大dopple频率; 128 | %t_interval为离散信道抽样时间间隔,等于OFDM符号长度/(子载波个数+cp长度lp); 129 | %counter各径间隔记录 130 | %count_begin本次产生信道开始记录的初始位置 131 | %no各径用于叠加形成Raleigh衰落的正弦波条数 132 | t_shift=round(delay/t_interval);%归一化各径延时 133 | [nl,l]=size(input_sig); 134 | output_sig=zeros(size(input_sig)); 135 | chann_l=nl*l;%信道采样点数,若一个调制符号采样一个信道点,则信道采样点数等于输入信号中的调制符号个数 136 | selec_ray_chan=zeros(num,chann_l);%初始化频率选择性信道,径数=num 137 | pow_per_channel=10.^(var_pow/10);%各径功率线性化,从dB转变成线性 138 | total_pow_allchan=sum(pow_per_channel(1:num));%各径功率之和 139 | %以下for循环产生相互独立的num条rayleigh信道 140 | for k=1:num 141 | atts=sqrt(pow_per_channel(k)); 142 | selec_ray_chan(k,:)=atts*rayleigh_fade(chann_l,t_interval,fd,counter_begin+k*1000,no(k))/sqrt(total_pow_allchan); 143 | end 144 | %以下计算信道频率响应值,行数与载波数相同,列数与符号个数相同 145 | N_carrier=nl-cp_n; 146 | N_ofdm=l; 147 | selec_ray_channew=zeros(num,chann_l+N_ofdm*(N_carrier+cp_n)); 148 | selec_ray_channew(:,1:chann_l)=selec_ray_chan; 149 | Hk=zeros(N_carrier,N_ofdm); 150 | for kk=1:N_ofdm 151 | for ii=1:N_carrier 152 | sum1=0; 153 | for ll=1:num 154 | sum1=sum1+selec_ray_channew(ll,(kk-1)*(N_carrier+cp_n)+cp_n+ii+t_shift(ll))*exp(-sqrt(-1)*2*pi*(ii-1)*t_shift(ll)/N_carrier); 155 | end 156 | Hk(ii,kk)=sum1; 157 | end 158 | end 159 | for k=1:l 160 | input_sig_serial(((k-1)*nl+1):k*nl)=input_sig(:,k).';%输入信号矩阵转变成串行序列 161 | end 162 | delay_sig=zeros(num,chann_l);%初始化延时后的送入各径的信号,每径所含符号数为chann_l 163 | %以下for循环为各径的输入信号做延迟处理 164 | for f=1:num 165 | if t_shift(f)~=0 166 | delay_sig(f,1:t_shift(f))=zeros(1,t_shift(f)); 167 | end 168 | delay_sig(f,(t_shift(f)+1):chann_l)= input_sig_serial(1:(chann_l-t_shift(f))); 169 | end 170 | output_sig_serial=zeros(1,chann_l);%初始化输出信号串行序列 171 | %得到各径叠加后的输出信号序列 172 | for f=1:num 173 | output_sig_serial= output_sig_serial+selec_ray_chan(f,:).*delay_sig(f,:); 174 | end 175 | for k=1:l 176 | output_sig(:,k)=output_sig_serial(((k-1)*nl+1):k*nl).';%输出信号串行序列转变成与输入信号相同的矩阵形式,做为本函数输出 177 | end 178 | 179 | 180 | % rayleigh_fade.m 181 | function ray_chann=rayleigh_fade(nsamp,tstp,fd,counter,no) 182 | %****************** variables ************************* 183 | % idata : input Ich data 184 | % qdata : input Qch data 185 | % iout : output Ich data 186 | % qout : output Qch data 187 | % ramp : Amplitude contaminated by fading 188 | % rcos : Cosine value contaminated by fading 189 | % rsin : Cosine value contaminated by fading 190 | % nsamp : Number of samples to be simulated 191 | % tstp : Minimum time resolution 192 | % fd : maximum doppler frequency 193 | % no : number of waves in order to generate fading 194 | % counter : fading counter 195 | % flat : flat fading or not 196 | % (1->flat (only amplitude is fluctuated),0->nomal(phase and amplitude are fluctutated) 197 | %****************************************************** 198 | % no=25; 199 | if fd ~= 0.0 200 | ac0 = sqrt(1.0 ./ (2.0.*(no + 1))); % power normalized constant(ich) 201 | as0 = sqrt(1.0 ./ (2.0.*no)); % power normalized constant(qch) 202 | pai = 3.14159265; 203 | wm = 2.0.*pai.*fd; 204 | n = 4.*no + 2; 205 | ts = tstp; 206 | wmts = wm.*ts; 207 | paino = pai./no; 208 | 209 | xc=zeros(1,nsamp); 210 | xs=zeros(1,nsamp); 211 | ic=[1:nsamp]+counter; 212 | 213 | for nn = 1: no 214 | cwn = cos( cos(2.0.*pai.*nn./n).*ic.*wmts ); 215 | xc = xc + cos(paino.*nn).*cwn; 216 | xs = xs + sin(paino.*nn).*cwn; 217 | end 218 | cwmt = sqrt(2.0).*cos(ic.*wmts); 219 | xc = (2.0.*xc + cwmt).*ac0; 220 | xs = 2.0.*xs.*as0; 221 | ray_chann=sqrt(xc.^2+xs.^2); 222 | else 223 | ray_chann=ones(1,nsamp); 224 | end 225 | 226 | % ************************end of file*********************************** 227 | -------------------------------------------------------------------------------- /rayleigh channel simulation/power_pt_arrat_v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/power_pt_arrat_v1.mat -------------------------------------------------------------------------------- /rayleigh channel simulation/qam_16.m: -------------------------------------------------------------------------------- 1 | %% this example process a binary data stream using a communication system that consists of 2 | % a baseband modulator, channel, and demodulator. 3 | %% The system's bit error rate (BER) is computed and the transmitted and received signals 4 | % are displayed in a constellation diagram. 5 | % ******************************************** 6 | 7 | % the qammod function dose not apply pulse shaping 8 | clc; 9 | clear; 10 | close all; 11 | M = 16; % Size of signal constellation 12 | k = log2(M); % number of bits per symbol 13 | n = 3e5; % numberi of bits to process 14 | numSamplePerSymbol = 1; % oversampling factor 15 | 16 | rng default; % use default random number generator 17 | dataIn = randi([0 1],n,1); %generate vector of binary data 18 | 19 | % plot the first 40 bits in a stem plot 20 | stem(1:40,dataIn(1:40),'filled'); 21 | title('random bits'); 22 | xlabel('Bit index'); 23 | ylabel('Binary value'); 24 | 25 | 26 | % convert teh binary signal to an integer-valued signal 27 | dataInMatrix = reshape(dataIn,length(dataIn)/k,k); 28 | dataSymbolsIn = bi2de(dataInMatrix); 29 | 30 | % plot the first 10 symbols 31 | stem(dataSymbolsIn(1:10)); 32 | title('Random Symbols'); 33 | xlabel('Symbol Index'); 34 | ylabel('Integer Value'); 35 | 36 | % Modulate using 16-QAM 37 | dataMod = qammod(dataSymbolsIn,M,'bin'); %binary coding, phase offset = 0 38 | dataModG = qammod(dataSymbolsIn,M); % Gray coding, Phase offset = 0; 39 | 40 | %sPlotFig = scatterplot(dataMod,1,0,'r.'); 41 | 42 | % calculate the SNR when the channel has an Eb/N0 = 10 dB. 43 | EbNo = 10; 44 | snr = EbNo + 10*log10(k) - 10*log10(numSamplePerSymbol); 45 | 46 | % pass the signal through AWGN channel 47 | receivedSignal = awgn(dataMod,snr,'measured'); 48 | receivedSignalG = awgn(dataModG,snr,'measured'); 49 | 50 | % create the constellation diagram 51 | sPlotFig = scatterplot(receivedSignal,1,0,'g.'); 52 | hold on; 53 | scatterplot(dataMod,1,0,'k*',sPlotFig); 54 | 55 | % demodulate 16-QAM 56 | dataSymbolsOut = qamdemod(receivedSignal,M,'bin'); 57 | dataSymbolsOutG = qamdemod(receivedSignalG,M); 58 | 59 | % convert the integer-valued signal to binary signal 60 | dataOutMatrix = de2bi(dataSymbolsOut,k); 61 | dataOut = dataOutMatrix(:); 62 | dataOutMatrixG = de2bi(dataSymbolsOutG,k); 63 | dataOutG = dataOutMatrixG(:); 64 | 65 | % compute teh system BER 66 | [numErrors,ber] = biterr(dataIn,dataOut); 67 | fprintf('\nThe binary coding bit error rate = %5.2e, base on %d errors(total bits %d)\n', ber, numErrors,n); 68 | 69 | [numErrorsG,berG] = biterr(dataIn,dataOutG); 70 | fprintf('\nThe binary coding bit error rate = %5.2e, base on %d errors(total bits %d)\n', berG, numErrorsG,n); 71 | 72 | 73 | % plot signal constellations 画出信号调制星座图 74 | M = 16; % Modulation order 75 | x = (0:15)'; % Integer input 76 | 77 | y1 = qammod(x,16,'bin'); 78 | scatterplot(y1) 79 | text(real(y1)+0.1, imag(y1), dec2bin(x)) 80 | title('16-QAM, Binary Symbol Mapping') 81 | axis([-4 4 -4 4]) 82 | 83 | y2 = qammod(x,16,'gray'); % 16-QAM output, Gray-coded 84 | scatterplot(y2) 85 | text(real(y2)+0.1, imag(y2), dec2bin(x)) 86 | title('16-QAM, Gray-coded Symbol Mapping') 87 | axis([-4 4 -4 4]) 88 | 89 | % pulse shaping using a rasied consine filter (a pair of square-root raised consine (RRC) filter) 90 | % 平方根升余弦滤波器(RRC) 91 | % 用来做signal shaping的,目的在一定的带宽要求下,尽量减少码间串扰(ISI) 92 | % 匹配滤波的目标也是为了修正ISI带来的信号畸变。 93 | % 升余弦滚降信号用来消除码间串扰,实际实现时采用的方式是由发送端的基带成形滤波器和接收端的匹配滤波器 94 | % 两个环节共同实现。传输系统的传递函数为二者的乘积,所以每个环节均为平方根升余弦滤波器,这样可以降低滤波器的是实现难度 95 | 96 | % 在数字通信中,实际发射出的信号是各个离散样值序列通过成形滤波器后的成形脉冲序列,匹配滤波器是为了使得 97 | % 抽样时刻信噪比最大。 98 | % 在发送端成形滤波器是根余弦滤波器,接收端同样使用根余弦滤波器匹配滤波时,既能够使得抽样时刻信噪比 99 | % 最高(即完成匹配滤波器的作用),又能够在一定的带限平坦信道中不引入码间干扰(满足Nyquist无码间干扰准则) 100 | 101 | 102 | % establis simulation framework 103 | M = 16; % size of signal constellation 104 | k = log2(M); % number of bits per symbol 105 | numBits = 3e5; 106 | numSamplePerSymbol = 4 107 | 108 | % create raised consine filter 109 | span = 10; % filter span in symbols 110 | rolloff = 0.25; % rolloff factor of filter 111 | 112 | rrcFilter = rcosdesign(rolloff,span,numSamplePerSymbol); 113 | fvtool(rrcFilter,'Analysis','Impulse'); % display teh RRC filter response 114 | 115 | % BER simulation 116 | rng default; % use default random number generator 117 | dataIn = randi([0 1], numBits, 1); % generate vector of binary data 118 | 119 | dataInMatrix = reshape(dataIn,length(dataIn)/k,k); 120 | dataSymbolsIn = bi2de(dataInMatrix); 121 | 122 | dataMod = qammod(dataSymbolsIn,M); 123 | 124 | % 滤波器的过采样和欠采样, 125 | txSignal = upfirdn(dataMod,rrcFilter,numSamplePerSymbol,1); 126 | 127 | EbNo = 10; 128 | snr = EbNo + 10*log10(k) - 10*log10(numSamplePerSymbol); 129 | 130 | % pass the signal through an AWGN channel 131 | rxSignal = awgn(txSignal,snr,'measured'); 132 | 133 | rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,numSamplePerSymbol); 134 | rxFiltSignal = rxFiltSignal(span+1:end-span); 135 | 136 | dataSymbolsOut = qamdemod(rxFiltSignal,M); 137 | 138 | dataOutMatrix = de2bi(dataSymbolsOut,k); 139 | dataOut = dataOutMatrix(:); 140 | 141 | % 从结果分析,错误比特差不多 142 | [numErrors, ber] = biterr(dataIn, dataOut); 143 | fprintf('\nThe bit error rate = %5.2e, based on %d errors\n', ... 144 | ber, numErrors); 145 | 146 | % create a scatter plot of the received signal before and after filtering 147 | h = scatterplot(sqrt(numSamplePerSymbol)*... 148 | rxSignal(1:numSamplePerSymbol*5e3),... 149 | numSamplePerSymbol,0,'g.'); 150 | hold on; 151 | scatterplot(rxFiltSignal(1:5e3),1,0,'kx',h); 152 | title('Received Signal, Before and After Filtering'); 153 | legend('Before Filtering','After Filtering'); 154 | axis([-5 5 -5 5]); % Set axis ranges 155 | hold off; 156 | 157 | 158 | 159 | %% error correction using a convolutional code (纠错) 160 | clc; 161 | clear; 162 | close all; 163 | % establish simulation framework 164 | M = 16; 165 | k = log2(M); 166 | numBits = 1e5; % 比特数,每四个比特为一个码 167 | numSamplePerSymbol = 4; % 每个码采样率 168 | 169 | rng default; 170 | dataIn = randi([0 1], numBits,1); 171 | 172 | % define a convolutional coding trellis for a rate 2/3 code 173 | % 该种样式是已经规定的。 174 | tPoly = poly2trellis([5 4],[23 35 0; 0 5 13]); 175 | codeRate = 2/3; 176 | dataEnc = convenc(dataIn,tPoly); 177 | 178 | dataEncMatrix = reshape(dataEnc,length(dataEnc)/k,k); 179 | dataSymbolsIn = bi2de(dataEncMatrix); 180 | 181 | dataMod = qammod(dataSymbolsIn,M); 182 | 183 | % create raised consine filter 184 | span = 10; % filter span in symbols 185 | rolloff = 0.25; % rolloff factor of filter 186 | 187 | rrcFilter = rcosdesign(rolloff,span,numSamplePerSymbol); 188 | 189 | txSignal = upfirdn(dataMod,rrcFilter,numSamplePerSymbol,1); 190 | 191 | EbNo = 10; 192 | snr = EbNo + 10*log10(k) - 10*log10(numSamplePerSymbol); 193 | 194 | % pass the signal through an AWGN channel 195 | rxSignal = awgn(txSignal,snr,'measured'); 196 | 197 | rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,numSamplePerSymbol); 198 | rxFiltSignal = rxFiltSignal(span+1:end-span); 199 | 200 | dataSymbolsOut = qamdemod(rxFiltSignal,M); 201 | 202 | dataOutMatrix = de2bi(dataSymbolsOut,k); 203 | codedDataOut = dataOutMatrix(:); 204 | 205 | % viterbi 解码 206 | traceBack = 16; 207 | numCodeWords = floor(length(codedDataOut)*2/3); 208 | dataOut = vitdec(codedDataOut(1:numCodeWords*3/2),tPoly,traceBack,'cont','hard'); 209 | decDelay = 2*traceBack; % Decoder delay, in bits 210 | 211 | [numErrors, ber] = ... 212 | biterr(dataIn(1:end-decDelay),dataOut(decDelay+1:end)); 213 | 214 | fprintf('\nThe bit error rate = %5.2e, based on %d errors\n', ... 215 | ber, numErrors) -------------------------------------------------------------------------------- /rayleigh channel simulation/ray_exp.m: -------------------------------------------------------------------------------- 1 | function y=ray_exp(x,taumaxf,Trms,nprofile) 2 | 3 | % this subroutine computes the channel correlation matrix (freq. domain); 4 | % nprofil: channel profile: 5 | % 1 - path delay distribution: exponential - tau(n) ~ exp(-tau(n)/Trms); 6 | % delay-power profile : uniform - 1/sqrt(N) - Hoeher's suggestion 7 | % Doppler power spectrum : Clarke's model 8 | % 9 | % 2 - path delay distribution: uniform 10 | % delay-power profile : exponential 11 | % Doppler power spectrum : flat 12 | %*************************************************************************% 13 | 14 | pi2=2*pi; 15 | 16 | %size(x) 17 | taumax=5*Trms; 18 | f_car = taumaxf/taumax; 19 | 20 | % nprofile=1 or 2 gives the same freq. correlation 21 | 22 | y = (1- exp(-taumax*(1/Trms + 1i * pi2 * f_car * x)))./ ... 23 | (Trms*(1-exp(-5))*(1/Trms + 1i*pi2*f_car*x)); 24 | %y = 1./(Trms*(1/Trms + 1i*pi2*f_car*x)); 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /rayleigh channel simulation/ray_jakes.m: -------------------------------------------------------------------------------- 1 | function y=ray_jakes(x,fmaxt,nprofile) 2 | % 3 | % this subroutine computes the normalized channel-correlation matrix in time 4 | % nprofile: channel profile: 5 | % 1 - path delay distribution: exponential 6 | % delay-power profile : uniform 7 | % Doppler power spectrum : Clarke's model 8 | % 9 | % 2 - path delay distribution: uniform 10 | % delay-power profile : exponential 11 | % Doppler power spectrum : flat 12 | %*************************************************************************% 13 | 14 | pi2=2*pi; 15 | 16 | if (nprofile==1) 17 | y=besselj(0,pi2*fmaxt*x); 18 | else 19 | y=pi*sinc(2*fmaxt*x); 20 | end 21 | 22 | -------------------------------------------------------------------------------- /rayleigh channel simulation/rayleigh.m: -------------------------------------------------------------------------------- 1 | function fk=rayleigh(fdts,fdmax,fcar,Trms,nprofile,K,L) 2 | 3 | % This function generates a frequency-selective (2D)Rayleigh fading process. 4 | % Specs as follows: 5 | % 1) Doppler power spectrum - Clarke's model; 6 | % 2) N paths, path delay tau(n) has exponential distribution C*exp(-tau(n)/Trms); 7 | % 3) Count only tau(n)'s in [0, 5Trms]; 8 | % 4) Equally-powered paths, according to Hoeher (Trans. VT, 1992) 9 | % 5) Composite transmitting/receiving filter: sinc function 10 | % 11 | % fk : complex output vector (channel frequency responses) 12 | % fdts : fd_max*T_symbol 13 | % fdmax : fd_max 14 | % fcar : carrier separation (OFDM: fcar=1/t. t=ts-delta) 15 | % Trms : rms delay 16 | % nprofile: channel profile: 17 | % 1 - path delay distribution: exponential 18 | % delay-power profile : uniform 19 | % Doppler power spectrum : Clarke's model 20 | % 21 | % 2 - path delay distribution: uniform 22 | % delay-power profile : exponential 23 | % Doppler power spectrum : flat 24 | % K : time index, k>= 0, k=0; initialization 25 | % L : number of carriers 26 | % 27 | % Prepared by Chengyang Li, 11/27/01 28 | 29 | pi2 = 2*pi; 30 | im=sqrt(-1); 31 | taumax = 5*Trms; 32 | 33 | if (nprofile==1) 34 | N = 50; 35 | tau = zeros(1,N); 36 | np = 1; 37 | 38 | % collect N paths with delay in [0, taumax] 39 | while (np<=N) 40 | %temp = exprnd(Trms); 41 | temp = -Trms * log(1-rand(1,1)); 42 | if (temp<=taumax) 43 | tau(1,np) = temp; 44 | np = np+1; 45 | end 46 | end 47 | 48 | % generate N fd's (normalized) and N random phases 49 | fd = fdts * cos(rand(1,N) * pi2); 50 | Phi = rand(1,N); % normalized by 2pi 51 | 52 | h = zeros(L,K); 53 | for k=1:K 54 | for l=1:L 55 | %temp = exp(1i*pi2*(Phi+fd*(k-1)-fcar*(l-1)*tau)); 56 | % typo corrected on 4/5/02 57 | temp = exp(im*pi2*(Phi+fd*(k-1)-fcar*(l-1)*tau)); 58 | h(l,k) = sum(temp); 59 | end 60 | end 61 | 62 | h = h./sqrt(N); 63 | 64 | % 4/5/02 comment out next two lines 65 | %fk = h./norm(h(:,1)); 66 | %fk = fk.'; 67 | fk=h.'; 68 | 69 | 70 | % 4/5/02 Ufuk: the following accomplish pulse shaping 71 | else 72 | N = 5; 73 | tau_n = rand(N,1) * taumax; % path delay uniformly distributed in [0,taumax] 74 | nsample = K; 75 | Fs = fdmax/fdts; % Fs = 1/T_symbol - sampling rate 76 | [b,a] = butter(8,fdmax/(Fs/2)); 77 | 78 | chn = 9000+nsample; 79 | alpha=diag(sqrt(exp(-tau_n/Trms)/2)) * (randn(N,chn) + 1i*randn(N,chn)); 80 | temp = zeros(size(alpha)); 81 | for n = 1:N 82 | temp(n,:) = filter(b,a,alpha(n,:)); 83 | end 84 | alpha = temp(:,9001:9000+nsample); 85 | 86 | temp = zeros(L,N); 87 | for n = 1:N 88 | temp(:,n) = exp(-1i*pi2*tau_n(n)*fcar*(0:L-1)'); 89 | end 90 | 91 | fek = temp * alpha; 92 | fk = fek.'/norm(fek(:,1)); 93 | end 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /rayleigh channel simulation/rayleighchann_simulation.m: -------------------------------------------------------------------------------- 1 | % backscattering simulation 2 | % Table B.2.1-2 Extended Pedestrian A model (EPA) rayleigh fading channel model 3 | % Excess tap delay[ns/10] Relative power[dB] 4 | % 0 0.0 5 | % 30 -1.0 6 | % 70 -2.0 7 | % 90 -3.0 8 | % 110 -8.0 9 | % 190 -17.2 10 | % 410 -20.8 11 | 12 | 13 | %% 该部分测试正弦信号经过rayleigh衰减信道,和经过rayleigh衰减信道后并添加部分噪声后的 信号功率的比较 14 | 15 | clc; 16 | clear; 17 | close all; 18 | 19 | f1=900e6; % 信号频率900MHz 20 | N=20; % 信号周期内的采样点数 21 | Fs=N*f1; % sampling frequency, 采样频率 22 | T = 1/Fs; % sampling period, 采样周期 23 | L = 200*N; % length of signal 24 | 25 | t=(0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 26 | A = 1; % 信号幅值 27 | 28 | %% 构造信号 29 | source = A*sin(2*pi*f1*t); 30 | 31 | figure(1); 32 | %% display the signal 33 | plot(t,source); 34 | axis([0 inf -1.5 1.5]); 35 | title('sine signal'); 36 | xlabel(['Time(f=',num2str(f1),')']) 37 | ylabel('Amplitude/V'); 38 | 39 | 40 | data_after_fft = fft(source,L); %对信号进行快速fourier变换 41 | mag_fft = abs(data_after_fft); %求得Fourier变换后的幅值 42 | 43 | f = (1:L/2)*Fs/L; %频率序列 44 | %% 绘出随频率变化的振幅 45 | figure; 46 | plot(f,mag_fft(1:L/2)*2/L); 47 | xlabel('Frequency/Hz'); 48 | ylabel('Amplitude');title('N=10000');grid on; 49 | 50 | % %% 通过三种不同方式计算信号功率 51 | % power_theoretical = (A^2/4)*2; % 理论平均功率 52 | % power_theoretical_db = 10*log10(power_theoretical/2) 53 | 54 | power_timedomain = sum(abs(source).^2)/length(source); 55 | power_timedomain_db = 10*log10(power_timedomain/2) 56 | 57 | % 计算该信号的功率谱 58 | figure; 59 | periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 60 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 61 | power_freqdomain = bandpower(Pxx_hamming, F, 'psd'); 62 | power_freqdomain_db = 10*log10(power_freqdomain/2) 63 | 64 | 65 | %构造rayleigh信道 66 | delay_vector = [0, 30, 70, 90, 110, 190, 410]*1e-10; % Discrete delays of four-path channel (s) 67 | gain_vector = [0 -1.0 -2.0 -3.0 -8.0 -17.2 -20.8]; % Average path gains (dB) 68 | max_Doppler_shift = 160; % Maximum Doppler shift of diffuse components (Hz) 69 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 70 | 71 | %% 经过rayleigh信道,且将保持该信道 72 | rayleigh_chan.ResetBeforeFiltering = 0; 73 | data_after_rayleigh = filter(rayleigh_chan,source); 74 | 75 | % 功率谱,并计算整个信号的功率 76 | [Pxx_hamming_after_rayleigh, F_after_rayleigh]= periodogram(data_after_rayleigh, hamming(length(data_after_rayleigh)),[],Fs,'centered', 'psd'); 77 | power_freqdomain_after_rayleigh = bandpower(Pxx_hamming_after_rayleigh, F_after_rayleigh, 'psd'); 78 | power_freqdomain_after_rayleigh_db = 10*log10(power_freqdomain_after_rayleigh/2) 79 | 80 | 81 | %%========================================================== 82 | rayleigh_chan.ResetBeforeFiltering = 0; 83 | data_after_rayleigh2 = filter(rayleigh_chan,source); 84 | 85 | SNR=10*log10(10); 86 | data_after_awgn=awgn(data_after_rayleigh2,SNR,'measured'); 87 | 88 | % 功率谱,并计算整个信号的功率 89 | [Pxx_hamming_after_rayleigh2, F_after_rayleigh2]= periodogram(data_after_awgn, hamming(length(data_after_awgn)),[],Fs,'centered', 'psd'); 90 | power_freqdomain_after_rayleigh2 = bandpower(Pxx_hamming_after_rayleigh2, F_after_rayleigh2, 'psd'); 91 | power_freqdomain_after_rayleigh_db2 = 10*log10(power_freqdomain_after_rayleigh2/2) 92 | 93 | figure; 94 | plot(t,real(data_after_rayleigh)); 95 | %axis([0 inf -1.5 1.5]); 96 | title('sine signal after channel'); 97 | xlabel(['Time(f=',num2str(f1),')']) 98 | ylabel('Amplitude/V'); -------------------------------------------------------------------------------- /rayleigh channel simulation/scheme2_test.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | 10 | 11 | %% 仿真方案二,设备之间的密钥建立,但是在tag能够区分整个信号时,即不叠加两个信号 12 | 13 | clc; 14 | clear; 15 | close all; 16 | 17 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 18 | N = 10; % 信号周期内的采样点数 19 | Fs = N*f1; % sampling frequency, 采样频率 20 | T = 1/Fs; % sampling period, 采样周期 21 | L = 1000*N; % length of signal 22 | 23 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 24 | A = 4; % 信号幅值 25 | 26 | 27 | %% 构造初始信号 28 | source = A*sin(2*pi*f1*t); 29 | 30 | %% 计算初始信号的功率 31 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 32 | power_source = bandpower(Pxx_hamming, F, 'psd'); 33 | power_source_db = 10*log10(power_source/2); 34 | 35 | 36 | num = 1:10; 37 | 38 | power_source_array(num) = power_source_db; 39 | 40 | power_tag_array(num) = 0; 41 | 42 | power_pt_array(num) = 0; 43 | 44 | for index = num 45 | 46 | %% 测试PT传输信号到Alice时的信号功率 47 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 48 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 49 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 50 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 51 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 52 | 53 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 54 | rayleigh_chan_a.ResetBeforeFiltering = 0; 55 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 56 | 57 | %% 设置高斯噪声与信号的信噪比 58 | SNR_tag_a = 8; 59 | %% 添加高斯噪声 60 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 61 | 62 | %% 计算在tag端接收信号的功率 63 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 64 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 65 | power_tag_a_db = 10*log10(power_tag_a/2); 66 | 67 | power_tag_a_array(index) = power_tag_a; 68 | 69 | 70 | %%********************************************************************************************** 71 | %% 测试PT传输信号到Bob时的信号功率 72 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 73 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-9; % Discrete delays of four-path channel (s) 74 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 75 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 76 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 77 | 78 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 79 | rayleigh_chan_b.ResetBeforeFiltering = 0; 80 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 81 | 82 | %% 设置高斯噪声与信号的信噪比 83 | SNR_tag_b = 9; 84 | %% 添加高斯噪声 85 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 86 | 87 | %% 计算在tag端接收信号的功率 88 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 89 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 90 | power_tag_b_db = 10*log10(power_tag_b/2); 91 | 92 | power_tag_b_array(index) = power_tag_b; 93 | 94 | 95 | %%********************************************************************************************** 96 | %% Alice的反射路径,将信号反射给Bob 97 | coeffi_a = 1.0; %% 反射因子 98 | data_a_back = data_tag_a.*coeffi_a; 99 | 100 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 101 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 102 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 103 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 104 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 105 | 106 | %% 反射后,信号经过rayleigh信道 107 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 108 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 109 | 110 | %% 为叠加信号添加高斯噪声 111 | SNR_tag_b = 9; 112 | data_b = awgn(back_after_rayleigh_ab,SNR_tag_b,'measured'); 113 | 114 | %% 计算在Bob端接收信号的功率 115 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 116 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 117 | power_b_db = 10*log10(power_b/2); 118 | 119 | power_b_array(index) = power_b; 120 | 121 | %%********************************************************************************************** 122 | %% bob的反射路径,将信号反射给Alice 123 | coeffi_b = 1.0; %% 反射因子 124 | data_b_back = data_tag_b.*coeffi_b; 125 | 126 | %% 使用与Alice到Bob之间的信道模型 127 | % %% 构造rayleigh信道,表示Alice与Bob之间的信道 128 | % delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 129 | % gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 130 | % max_Doppler_shift_ab = 10; % Maximum Doppler shift of diffuse components (Hz) 131 | % rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 132 | 133 | %% 反射后,信号经过rayleigh信道 134 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 135 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 136 | 137 | %% 为叠加信号添加高斯噪声 138 | SNR_tag_a = 8; 139 | data_a = awgn(back_after_rayleigh_ba,SNR_tag_a,'measured'); 140 | 141 | 142 | %% 计算在Alice端接收信号的功率 143 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 144 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 145 | power_a_db = 10*log10(power_a/2); 146 | 147 | power_a_array(index) = power_a; 148 | 149 | end 150 | 151 | figure; 152 | plot(num,power_tag_a_array); 153 | hold on; 154 | plot(num,power_tag_b_array); 155 | hold on; 156 | plot(num,power_b_array); 157 | hold on; 158 | plot(num,power_a_array); 159 | legend('PT-a','pt-b','total-b','total-a'); 160 | grid on; 161 | 162 | 163 | figure; 164 | plot(num,power_a_array.*power_tag_a_array); 165 | hold on; 166 | plot(num,power_b_array.*power_tag_b_array); 167 | legend('alice','bob'); 168 | grid on; 169 | 170 | %% 计算序列的相关性 171 | r = corr2(power_b_array,power_a_array) 172 | r = corr2(power_a_array.*power_tag_a_array,power_b_array.*power_tag_b_array) -------------------------------------------------------------------------------- /rayleigh channel simulation/scheme2_test2.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | %% 之后的信号都这个模型的基础上进行的修改 10 | 11 | %% 仿真方案二,设备之间的密钥建立,但是在tag能够区分整个信号时,即不叠加两个信号 12 | 13 | clc; 14 | clear; 15 | close all; 16 | 17 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 18 | N = 10; % 信号周期内的采样点数 19 | Fs = N*f1; % sampling frequency, 采样频率 20 | T = 1/Fs; % sampling period, 采样周期 21 | L = 10000*N; % length of signal 22 | 23 | t = (0:(L-1))*T; % 采样时间s,fs的值越大,出来的波形失真越小 24 | A = 4; % 信号幅值 25 | 26 | %% 构造调制1和-1序列 27 | f_seq = 22.5e6; %% 45MHz 28 | value = 1; 29 | for index = 1:L 30 | base_signal(index) = value; 31 | if mod(index, (Fs/f_seq)/2) == 0 32 | value = 0-value; 33 | end 34 | end 35 | 36 | % base_signal=square(2*pi*f_seq*t); 37 | % sum(base_signal) 38 | 39 | 40 | 41 | %% 构造初始信号 42 | source = A*sin(2*pi*f1*t); 43 | 44 | plot(t(1:200),source(1:200),t(1:200),base_signal(1:200)) 45 | 46 | %% 计算初始信号的功率 47 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 48 | power_source = bandpower(Pxx_hamming, F, 'psd'); 49 | power_source_db = 10*log10(power_source/2); 50 | 51 | 52 | num = 1:1000; 53 | 54 | power_source_array(num) = power_source_db; 55 | 56 | power_tag_array(num) = 0; 57 | 58 | power_pt_array(num) = 0; 59 | 60 | for index = num 61 | 62 | %% 测试PT传输信号到Alice时的信号功率 63 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 64 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 65 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 66 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 67 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 68 | 69 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 70 | rayleigh_chan_a.ResetBeforeFiltering = 0; 71 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 72 | 73 | %% 设置高斯噪声与信号的信噪比 74 | SNR_tag_a = 8; 75 | %% 添加高斯噪声 76 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 77 | 78 | %% 计算在tag端接收信号的功率 79 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 80 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 81 | power_tag_a_db = 10*log10(power_tag_a/2); 82 | 83 | power_tag_a_array(index) = power_tag_a; 84 | 85 | 86 | %%********************************************************************************************** 87 | %% 测试PT传输信号到Bob时的信号功率 88 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 89 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-9; % Discrete delays of four-path channel (s) 90 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 91 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 92 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 93 | 94 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 95 | rayleigh_chan_b.ResetBeforeFiltering = 0; 96 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 97 | 98 | %% 设置高斯噪声与信号的信噪比 99 | SNR_tag_b = 9; 100 | %% 添加高斯噪声 101 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 102 | 103 | %% 计算在tag端接收信号的功率 104 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 105 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 106 | power_tag_b_db = 10*log10(power_tag_b/2); 107 | 108 | power_tag_b_array(index) = power_tag_b; 109 | 110 | 111 | %%********************************************************************************************** 112 | %% Alice的反射路径,将信号反射给Bob 113 | coeffi_a = 0.9; %% 反射因子 114 | data_a_coeffi = data_tag_a.*coeffi_a; 115 | 116 | %% 进行ASK调制,使用已经设置好的方波序列 117 | data_a_back = data_a_coeffi.*base_signal; 118 | 119 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 120 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 121 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 122 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 123 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 124 | 125 | %% 反射后,信号经过rayleigh信道 126 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 127 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 128 | 129 | %% Bob接收的信号为Alice反射信号和PT直传信号的叠加 130 | data_total_b = back_after_rayleigh_ab + data_after_rayleigh_b; 131 | 132 | %% 为叠加信号添加高斯噪声 133 | SNR_tag_b = 9; 134 | data_b = awgn(data_total_b,SNR_tag_b,'measured'); 135 | 136 | %% 计算在Bob端接收信号的功率 137 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 138 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 139 | power_b_db = 10*log10(power_b/2); 140 | 141 | power_b_array(index) = power_b; 142 | 143 | %%********************************************************************************************** 144 | %% bob的反射路径,将信号反射给Alice 145 | coeffi_b = 0.9; %% 反射因子 146 | data_b_coeffi = data_tag_b.*coeffi_b; 147 | 148 | %% 进行ASK调制,使用已经设置好的方波序列 149 | data_b_back = data_b_coeffi.*base_signal; 150 | 151 | %% 使用与Alice到Bob之间的信道模型 152 | % %% 构造rayleigh信道,表示Alice与Bob之间的信道 153 | % delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 154 | % gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 155 | % max_Doppler_shift_ab = 10; % Maximum Doppler shift of diffuse components (Hz) 156 | % rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 157 | 158 | %% 反射后,信号经过rayleigh信道 159 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 160 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 161 | 162 | %% Alice接收的信号为Bob反射信号和PT直传信号的叠加 163 | data_total_a = back_after_rayleigh_ba + data_after_rayleigh_a; 164 | 165 | %% 为叠加信号添加高斯噪声 166 | SNR_tag_a = 8; 167 | data_a = awgn(data_total_a,SNR_tag_a,'measured'); 168 | 169 | 170 | %% 计算在Alice端接收信号的功率 171 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 172 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 173 | power_a_db = 10*log10(power_a/2); 174 | 175 | power_a_array(index) = power_a; 176 | 177 | end 178 | 179 | figure; 180 | plot(num,power_tag_a_array); 181 | hold on; 182 | plot(num,power_tag_b_array); 183 | hold on; 184 | plot(num,power_b_array); 185 | hold on; 186 | plot(num,power_a_array); 187 | legend('PT-a','PT-b','total-b','total-a'); 188 | grid on; 189 | 190 | 191 | %% 计算序列的相关性 192 | r = corr2(power_b_array,power_a_array) 193 | 194 | alice = (power_a_array-power_tag_a_array).*power_tag_a_array; 195 | bob = (power_b_array-power_tag_b_array).*power_tag_b_array; 196 | 197 | cor = corr2(alice,bob) 198 | 199 | 200 | 201 | figure; 202 | plot(num,(power_a_array-power_tag_a_array).*power_tag_a_array); 203 | hold on; 204 | plot(num,(power_b_array-power_tag_b_array).*power_tag_b_array); 205 | legend('alice','bob'); 206 | grid on; 207 | 208 | figure; 209 | plot(num,10*log10((power_a_array-power_tag_a_array).*power_tag_a_array)); 210 | hold on; 211 | plot(num,10*log10((power_b_array-power_tag_b_array).*power_tag_b_array)); 212 | legend('alice','bob'); 213 | grid on; -------------------------------------------------------------------------------- /rayleigh channel simulation/scheme2_v1.m: -------------------------------------------------------------------------------- 1 | % Table is a rayleigh fading channel model in indoor 2 | % Excess tap delay[ns] Relative power[dB] 3 | % 0 0.0 4 | % 50 -3.0 5 | % 110 -10.0 6 | % 170 -18.0 7 | % 290 -26.0 8 | % 310 -32.0 9 | 10 | 11 | %% 仿真方案二,设备之间的密钥建立 12 | 13 | clc; 14 | clear; 15 | close all; 16 | 17 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 18 | f2 = 950e6; % 信号频率900MHz,信号周期为10/9 ns 19 | N = 10; % 信号周期内的采样点数 20 | Fs = N*f1; % sampling frequency, 采样频率 21 | T = 1/Fs; % sampling period, 采样周期 22 | L = 1000*N; % length of signal 23 | 24 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 25 | A = 4; % 信号幅值 26 | 27 | 28 | %% 构造初始信号 29 | source = A*sin(2*pi*f1*t) + A*sin(2*pi*f2*t); 30 | 31 | %% 计算初始信号的功率 32 | [Pxx_hamming, F]= periodogram(source, hamming(length(source)),[],Fs,'centered', 'psd'); 33 | power_source = bandpower(Pxx_hamming, F, 'psd'); 34 | power_source_db = 10*log10(power_source/2); 35 | 36 | 37 | num = 1:100; 38 | 39 | power_source_array(num) = power_source_db; 40 | 41 | power_tag_array(num) = 0; 42 | 43 | power_pt_array(num) = 0; 44 | 45 | for index = num 46 | 47 | %% 测试PT传输信号到Alice时的信号功率 48 | %% 构造rayleigh信道一,表示PT与Alice之间的信道 49 | delay_vector_a = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 50 | gain_vector_a = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 51 | max_Doppler_shift_a = 50; % Maximum Doppler shift of diffuse components (Hz) 52 | rayleigh_chan_a = rayleighchan(T,max_Doppler_shift_a,delay_vector_a,gain_vector_a); 53 | 54 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 55 | rayleigh_chan_a.ResetBeforeFiltering = 0; 56 | data_after_rayleigh_a = filter(rayleigh_chan_a,source); 57 | 58 | %% 设置高斯噪声与信号的信噪比 59 | SNR_tag_a = 8; 60 | %% 添加高斯噪声 61 | data_tag_a = awgn(data_after_rayleigh_a,SNR_tag_a,'measured'); 62 | 63 | %% 计算在tag端接收信号的功率 64 | [Pxx_hamming_tag_a, F_tag_a] = periodogram(data_tag_a,hamming(length(data_tag_a)),[],Fs,'centered','psd'); 65 | power_tag_a = bandpower(Pxx_hamming_tag_a,F_tag_a,'psd'); 66 | power_tag_a_db = 10*log10(power_tag_a/2); 67 | 68 | power_tag_a_array(index) = power_tag_a; 69 | 70 | 71 | %%********************************************************************************************** 72 | %% 测试PT传输信号到Bob时的信号功率 73 | %% 构造rayleigh信道二,表示PT与Bob之间的信道 74 | delay_vector_b = [0, 55, 120, 190, 310, 330]*1e-9; % Discrete delays of four-path channel (s) 75 | gain_vector_b = [0 -4.0 -11.0 -20.0 -28.0 -36.0]; % Average path gains (dB) 76 | max_Doppler_shift_b = 55; % Maximum Doppler shift of diffuse components (Hz) 77 | rayleigh_chan_b = rayleighchan(T,max_Doppler_shift_b,delay_vector_b,gain_vector_b); 78 | 79 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 80 | rayleigh_chan_b.ResetBeforeFiltering = 0; 81 | data_after_rayleigh_b = filter(rayleigh_chan_b,source); 82 | 83 | %% 设置高斯噪声与信号的信噪比 84 | SNR_tag_b = 9; 85 | %% 添加高斯噪声 86 | data_tag_b = awgn(data_after_rayleigh_b,SNR_tag_b,'measured'); 87 | 88 | %% 计算在tag端接收信号的功率 89 | [Pxx_hamming_tag_b, F_tag_b] = periodogram(data_tag_b,hamming(length(data_tag_b)),[],Fs,'centered','psd'); 90 | power_tag_b = bandpower(Pxx_hamming_tag_b,F_tag_b,'psd'); 91 | power_tag_b_db = 10*log10(power_tag_b/2); 92 | 93 | power_tag_b_array(index) = power_tag_b; 94 | 95 | 96 | %%********************************************************************************************** 97 | %% Alice的反射路径,将信号反射给Bob 98 | coeffi_a = 1.0; %% 反射因子 99 | data_a_back = data_tag_a.*coeffi_a; 100 | 101 | %% 构造rayleigh信道,表示Alice与Bob之间的信道 102 | delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 103 | gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 104 | max_Doppler_shift_ab = 100; % Maximum Doppler shift of diffuse components (Hz) 105 | rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 106 | 107 | %% 反射后,信号经过rayleigh信道 108 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 109 | back_after_rayleigh_ab = filter(rayleigh_chan_ab,data_a_back); 110 | 111 | %% Bob接收的信号为Alice反射信号和PT直传信号的叠加 112 | data_total_b = back_after_rayleigh_ab + data_after_rayleigh_b; 113 | 114 | %% 为叠加信号添加高斯噪声 115 | SNR_tag_b = 9; 116 | data_b = awgn(data_total_b,SNR_tag_b,'measured'); 117 | 118 | %% 计算在Bob端接收信号的功率 119 | [Pxx_hamming_b, F_b] = periodogram(data_b,hamming(length(data_b)),[],Fs,'centered','psd'); 120 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 121 | power_b_db = 10*log10(power_b/2); 122 | 123 | power_b_array(index) = power_b; 124 | 125 | %%********************************************************************************************** 126 | %% bob的反射路径,将信号反射给Alice 127 | coeffi_b = 1.0; %% 反射因子 128 | data_b_back = data_tag_b.*coeffi_b; 129 | 130 | %% 使用与Alice到Bob之间的信道模型 131 | % %% 构造rayleigh信道,表示Alice与Bob之间的信道 132 | % delay_vector_ab = [0, 4, 10, 19, 31, 43]*1e-9; % Discrete delays of four-path channel (s) 133 | % gain_vector_ab = [0 -1.0 -5.0 -10.0 -18.0 -26.0]; % Average path gains (dB) 134 | % max_Doppler_shift_ab = 10; % Maximum Doppler shift of diffuse components (Hz) 135 | % rayleigh_chan_ab = rayleighchan(T,max_Doppler_shift_ab,delay_vector_ab,gain_vector_ab); 136 | 137 | %% 反射后,信号经过rayleigh信道 138 | rayleigh_chan_ab.ResetBeforeFiltering = 0; 139 | back_after_rayleigh_ba = filter(rayleigh_chan_ab,data_b_back); 140 | 141 | %% Alice接收的信号为Bob反射信号和PT直传信号的叠加 142 | data_total_a = back_after_rayleigh_ba + data_after_rayleigh_a; 143 | 144 | %% 为叠加信号添加高斯噪声 145 | SNR_tag_a = 8; 146 | data_a = awgn(data_total_a,SNR_tag_a,'measured'); 147 | 148 | 149 | %% 计算在Alice端接收信号的功率 150 | [Pxx_hamming_a, F_a] = periodogram(data_a,hamming(length(data_a)),[],Fs,'centered','psd'); 151 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 152 | power_a_db = 10*log10(power_a/2); 153 | 154 | power_a_array(index) = power_a; 155 | 156 | end 157 | 158 | figure; 159 | plot(num,power_tag_a_array); 160 | hold on; 161 | plot(num,power_tag_b_array); 162 | hold on; 163 | plot(num,power_b_array); 164 | hold on; 165 | plot(num,power_a_array); 166 | legend('PT-a','pt-b','total-b','total-a'); 167 | grid on; 168 | 169 | 170 | figure; 171 | plot(num,(power_a_array-power_tag_a_array).*power_tag_a_array); 172 | hold on; 173 | plot(num,(power_b_array-power_tag_b_array).*power_tag_b_array); 174 | legend('alice','bob'); 175 | grid on; 176 | 177 | %% 计算序列的相关性 178 | r = corr2(power_b_array,power_a_array) 179 | -------------------------------------------------------------------------------- /rayleigh channel simulation/scheme_test2_array_v1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/scheme_test2_array_v1.mat -------------------------------------------------------------------------------- /rayleigh channel simulation/single_sin_power.m: -------------------------------------------------------------------------------- 1 | % measuring the power of deterministic periods signals 2 | 3 | clc; 4 | close all; 5 | Fs = 1024; % 采样频率 6 | t = 0:1/Fs:1-(1/Fs); % 时间序列 7 | A = 1; % Vpeak 8 | F1 = 128; % Hz,信号频率 9 | x = A*sin(2*pi*t*F1); 10 | 11 | idx = 1:128; 12 | % figure; 13 | % plot(t(idx),x(idx)); 14 | % grid; 15 | % ylabel('Amplitude'); 16 | % xlabel('Time (sec)'); 17 | % axis tight; 18 | 19 | power_theoretical = (A^2/4)*2 % 理论平均功率 20 | power_theoretical_db = 10*log10(power_theoretical/2) 21 | 22 | %% Measuring the Power of a Single Sinusoid 23 | % figure; 24 | % % 在计算的过程中已经画出图形,后面都是对图形的调整 25 | % periodogram(x, hamming(length(x)),[],Fs,'centered', 'power'); 26 | % v = axis; 27 | % axis([v(1) v(2) -10 -5.5]) 28 | % hgcf = gcf; % 图形句柄 29 | % hgcf.Color = [1 1 1]; 30 | 31 | 32 | % %% Estimating the Power of a Single Sinusoid via PSD 33 | figure 34 | power_freqdomain = periodogram(x, hamming(length(x)), [], Fs, 'centered', 'psd'); 35 | v = axis; 36 | axis([v(1) v(2) -10 -5.5]) 37 | hgcf = gcf; 38 | hgcf.Color = [1 1 1]; 39 | 40 | %% we notice in thsi plot is that teh peaks of the spectrum plot do not 41 | %% have the same height as when we plotted the power spectrum. 42 | %% because when taking Power Spectral density (PSD) measurement it's the erea 43 | %% under the curve that matters. 44 | %% 即峰值线面的曲线部分也会占据一部分能量,所以导致峰值下降。 45 | 46 | 47 | [Pxx_hamming, F] = periodogram(x, hamming(length(x)), [], Fs, 'psd'); 48 | %% 经过功率谱变换后,可以利用这个公式计算信号频率域上的功率 49 | power_freqdomain = bandpower(Pxx_hamming, F, 'psd'); 50 | 51 | %% 下面公式是计算信号时间域上的公式 52 | power_timedomain = sum(abs(x).^2)/length(x); 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /rayleigh channel simulation/spectrum_analysisr.m: -------------------------------------------------------------------------------- 1 | %========================================================================== 2 | %Name: spectrum_analysis.m 3 | %Desc: 以高斯脉冲信号为例,求解其频谱、双边功率谱、单边功率谱、双边功率谱密度、 4 | % 单边功率谱密度,这里高斯信号的半波全宽FWHM=50ps,中心点位于2.5ns处。 5 | %Parameter: 6 | %Return: 7 | %Author: wangpu(wangpu03@gmail.com) 8 | %Date: 2018-2-21 9 | %高斯函数公式有两种表达方式 a*exp(-((x-b)/2c)^2),和a*exp(-((x-b)/c)^2) 10 | %其中c和2c都是反映脉冲陡度。对于前者,2ln2c表示波峰半高度时的宽度,后者则为2lnc 11 | 12 | %fftshift是针对频域的,将FFT的DC分量移到频谱中心,操作就是对换数据的左右两边 13 | %例子 14 | %x=[1 2 3 4] 15 | %fftshift(x) -> [3 4 1 2] 16 | %直接用fft得出的数据与频率不是对应的,fftshift将其纠正过来 17 | %如果期望绘制的幅频图的频率范围为0~fs,则无需运行fftshift变换 18 | %如果期望绘制的幅频图的频率范围为-fs/2~fs/2,则需要运行fftshift变换 19 | %========================================================================= 20 | 21 | clc; 22 | clear; 23 | FWHM=50e-12; %高斯信号FWHM宽度,为50ps 24 | time_window=100*FWHM; %高斯信号的采样窗口宽度,该值决定了傅里叶变换后的频率分辨率 25 | Ns=2048; %采样点 26 | dt=time_window/(Ns-1); %采样时间间隔 27 | t=0:dt:time_window; %采样时间 28 | 29 | gauss_time=exp(-0.5*(2*sqrt(2*log(2))*(t-2.5e-9)/FWHM).^2); %高斯脉冲,中心位于2.5ns处。 30 | 31 | plot(t*1e+9,gauss_time,'linewidth',0.5); 32 | xlabel('Time/ns'); 33 | ylabel('Amplitude/V'); 34 | title('Gauss pulse'); 35 | 36 | 37 | %===========以下计算双边谱、双边功率谱、双边功率谱密度================= 38 | gauss_spec=fftshift(fft(ifftshift(gauss_time))); %傅里叶变换,并且进行fftshift移位操作。 39 | gauss_spec=gauss_spec/Ns; %求实际的幅度值; 40 | df=1/time_window; %频率分辨率 41 | k=floor(-(Ns-1)/2:(Ns-1)/2); 42 | % k=0:Ns-1; 43 | double_f=k*df; %双边频谱对应的频点 44 | 45 | 46 | figure(2); %幅度谱 47 | plot(double_f*1e-9,abs(gauss_spec),'linewidth',0.5); 48 | xlabel('Frequency/GHz'); 49 | ylabel('Amplitude/V'); 50 | title('double Amplitude spectrum'); 51 | 52 | 53 | figure(3); %相位谱 54 | plot(double_f*1e-9,angle(gauss_spec),'linewidth',0.5); 55 | xlabel('Frequency/GHz'); 56 | ylabel('Phase/rad'); 57 | title('double Phase spectrum'); 58 | 59 | 60 | figure(4); %功率谱 61 | double_power_spec_W=abs(gauss_spec).^2; %双边功率谱,单位W; 62 | double_power_spec_mW=double_power_spec_W*1e+3; %双边功率谱,单位mW; 63 | double_power_spec_dBm=10*log10(double_power_spec_mW); %双边功率谱,单位dBm; 64 | 65 | plot(double_f*1e-9,double_power_spec_dBm,'linewidth',0.5); 66 | xlabel('Frequency/GHz'); 67 | ylabel('Power/dBm'); 68 | title('double Power spectrum'); 69 | 70 | 71 | figure(5); %功率谱密度 72 | double_power_specD_W=abs(gauss_spec).^2/(df); %双边功率谱密度,单位W/Hz 73 | double_power_specD_mW=double_power_specD_W*1e+3; %双边功率谱密度,单位mW/Hz 74 | double_power_specD_dBm=10*log10(double_power_specD_mW); %双边功率谱密度,单位dBm/Hz 75 | 76 | plot(double_f*1e-9,double_power_specD_dBm,'linewidth',0.5); 77 | xlabel('Frequency/GHz'); 78 | ylabel('Power/(dBm/Hz)'); 79 | title('double power spectrum Density'); 80 | 81 | 82 | %==========以下计算单边谱、单边功率谱及单边功率谱密度========= 83 | gauss_spec=fft(ifftshift(gauss_time)); %计算单边谱无需fftshift 84 | gauss_spec=gauss_spec/Ns; %计算真实的幅度值 85 | single_gauss_spec=gauss_spec(1:floor(Ns/2)); 86 | single_f=(0:floor(Ns/2)-1)*df; 87 | 88 | 89 | figure(6); %幅度谱 90 | plot(single_f*1e-9,abs(single_gauss_spec),'linewidth',0.5); 91 | xlabel('Frequency/GHz'); 92 | ylabel('Amplitude/V'); 93 | title('single Amplitude spectrum'); 94 | 95 | 96 | figure(7); %相位谱 97 | plot(single_f*1e-9,angle(single_gauss_spec),'linewidth',0.5); 98 | xlabel('Frequency/GHz'); 99 | ylabel('Phase/rad'); 100 | title('single Phase spectrum'); 101 | 102 | figure(8);%功率谱 103 | double_power_spec_W=abs(gauss_spec).^2; 104 | single_power_spec_W=2*double_power_spec_W(1:floor(Ns/2)); %单边功率谱,单位W 105 | single_power_spec_mW=single_power_spec_W*1e+3; %单边功率谱,单位mW; 106 | single_power_spec_dBm=10*log10(single_power_spec_mW); %双边功率谱,单位dBm; 107 | plot(single_f*1e-9,single_power_spec_dBm,'linewidth',0.5); 108 | xlabel('Frequency/GHz'); 109 | ylabel('Power/dBm'); 110 | title('single Power spectrum'); 111 | 112 | 113 | figure(9);%功率谱密度 114 | double_power_specD_W=abs(gauss_spec).^2/(df); 115 | single_power_specD_W=2*double_power_specD_W(1:floor(Ns/2)); %单边功率谱密度,单位W/Hz 116 | single_power_specD_mW=single_power_specD_W*1e+3; %单边功率谱密度,单位mW/Hz 117 | single_power_specD_dBm=10*log10(single_power_specD_mW); %单边功率谱密度,单位dBm/Hz 118 | 119 | plot(single_f*1e-9,single_power_specD_mW,'linewidth',0.5); 120 | xlabel('Frequency/GHz'); 121 | ylabel('Power/(dBm/Hz)'); 122 | title('single power spectrum density'); -------------------------------------------------------------------------------- /rayleigh channel simulation/test_bessel.m: -------------------------------------------------------------------------------- 1 | %test bessel function of first kind 2 | 3 | X = 0:0.1:20; 4 | J = zeros(5, 201); 5 | 6 | for i = 0:4 7 | J(i+1,:) = besselj(i,X); 8 | end 9 | 10 | plot(X,J,'LineWidth',1.5) 11 | axis([0 20 -0.5 1]); -------------------------------------------------------------------------------- /rayleigh channel simulation/test_function.m: -------------------------------------------------------------------------------- 1 | % num = 100; 2 | % index = 1:num; 3 | % for i = index 4 | % disp(i); 5 | % end 6 | 7 | 8 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 9 | f2 = 950e6; % 信号频率900MHz,信号周期为10/9 ns 10 | N = 20; % 信号周期内的采样点数 11 | Fs = N*f1; % sampling frequency, 采样频率 12 | T = 1/Fs; % sampling period, 采样周期 13 | L = 20*N; % length of signal 14 | 15 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 16 | A = 4; % 信号幅值 17 | 18 | 19 | phase1 = 2*pi*rand(); 20 | 21 | %% 构造初始信号 22 | source1 = A*sin(2*pi*f1*t); 23 | [Pxx_hamming_b, F_b] = periodogram(source1,hamming(length(source1)),[],Fs,'centered','psd'); 24 | power_b = bandpower(Pxx_hamming_b,F_b,'psd'); 25 | power_b_db = 10*log10(power_b/2) 26 | 27 | phase2 = 2*pi*rand(); 28 | 29 | %% 构造初始信号 30 | source2 = A*sin(2*pi*f1*t); 31 | 32 | y = source1 + source2; 33 | 34 | [Pxx_hamming_a, F_a] = periodogram(y ,hamming(length(y )),[],Fs,'centered','psd'); 35 | power_a = bandpower(Pxx_hamming_a,F_a,'psd'); 36 | power_a_db = 10*log10(power_a/2) 37 | 38 | 39 | figure; 40 | plot(t,source1); 41 | hold on; 42 | plot(t,source2); 43 | 44 | grid on; 45 | 46 | plot(t,y); -------------------------------------------------------------------------------- /rayleigh channel simulation/test_power.m: -------------------------------------------------------------------------------- 1 | clear all 2 | Fs=1000; 3 | n=0:1/Fs:1; 4 | x=cos(2*pi*40*n)+3*cos(2*pi*100*n)+randn(size(n)); 5 | 6 | nfft=1024; 7 | window=boxcar(length(n)); 8 | [Pxx,f]=periodogram(x,window,nfft,Fs); 9 | P=10*log10(Pxx); 10 | plot(f,P); 11 | hold on; 12 | Pxx_1=abs(fft(x,nfft)).^2/length(n); 13 | t=0:round(nfft/2-1); 14 | f=t*Fs/nfft; 15 | P_1=10*log10(Pxx_1(t+1)); 16 | plot(f,P_1,'r'); 17 | legend('periodogram','??'); 18 | title('?????????'); -------------------------------------------------------------------------------- /rayleigh channel simulation/test_rayleighchan.m: -------------------------------------------------------------------------------- 1 | 2 | clc; 3 | f1 = 900e6; % 信号频率900MHz,信号周期为10/9 ns 4 | N = 10; % 信号周期内的采样点数 5 | Fs = N*f1; % sampling frequency, 采样频率 6 | T = 1/Fs; % sampling period, 采样周期 7 | L = 1000*N; % length of signal 8 | 9 | t = (0:L-1)*T; % 采样时间s,fs的值越大,出来的波形失真越小 10 | A = 4; % 信号幅值 11 | 12 | %% 设置高斯噪声 13 | SNR_tag = 10; 14 | 15 | %% 构造初始信号 16 | source = A*sin(2*pi*f1*t); 17 | 18 | 19 | %% 构造rayleigh信道 20 | delay_vector = [0, 50, 110, 170, 290, 310]*1e-9; % Discrete delays of four-path channel (s) 21 | gain_vector = [0 -3.0 -10.0 -18.0 -26.0 -32.0]; % Average path gains (dB) 22 | max_Doppler_shift = 50; % Maximum Doppler shift of diffuse components (Hz) 23 | rayleigh_chan = rayleighchan(T,max_Doppler_shift,delay_vector,gain_vector); 24 | 25 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 26 | rayleigh_chan.ResetBeforeFiltering = 1; 27 | data_after_rayleigh = filter(rayleigh_chan,source); 28 | 29 | %% 计算通过rayleigh信道后的信号功率 30 | [Pxx_hamming_after_rayleigh, F_after_rayleigh]= periodogram(data_after_rayleigh,... 31 | hamming(length(data_after_rayleigh)),[],Fs,'centered', 'psd'); 32 | power_after_rayleigh = bandpower(Pxx_hamming_after_rayleigh,... 33 | F_after_rayleigh, 'psd'); 34 | power_after_rayleigh_db = 10*log10(power_after_rayleigh/2) 35 | 36 | 37 | 38 | %% 初始信号经过rayleigh信道,并保持该信道特性用于下次反射 39 | %% if reset = 0, the fading process maintains continuity from one call to the next. 40 | rayleigh_chan.ResetBeforeFiltering = 0; 41 | data_after_rayleigh2 = filter(rayleigh_chan,source); 42 | 43 | %% 计算通过rayleigh信道后的信号功率 44 | [Pxx_hamming_after_rayleigh2, F_after_rayleigh2]= periodogram(data_after_rayleigh2,... 45 | hamming(length(data_after_rayleigh2)),[],Fs,'centered', 'psd'); 46 | power_after_rayleigh2 = bandpower(Pxx_hamming_after_rayleigh2,... 47 | F_after_rayleigh2, 'psd'); 48 | power_after_rayleigh_db2 = 10*log10(power_after_rayleigh2/2) 49 | 50 | isequal(data_after_rayleigh,data_after_rayleigh2) -------------------------------------------------------------------------------- /rayleigh channel simulation/test_signal.m: -------------------------------------------------------------------------------- 1 | %% 构造离散时间向量 2 | Fs = 1000; % sampling frequency, 采用频率 3 | T = 1/Fs; % sampling period, 采用周期 4 | L = 1000; % length of signal 5 | t = (0:L-1)*T; % time vector 6 | 7 | 8 | f1 = 50; 9 | f2 = 120; 10 | %% 构造信号 11 | % 信号包括一个振幅为0.7,频率为50Hz的正弦信号,一个振幅为1,频率为120的正弦信号 12 | S = 0.7*sin(2*pi*f1*t)+sin(2*pi*f2*t); 13 | 14 | %% 加噪声 15 | X = S + 2*randn(size(t)); 16 | 17 | 18 | %% spike signal 19 | N = 100; 20 | s = zeros(N,1); 21 | k = [20, 45, 70]; 22 | a = [2, -1, 1]; 23 | s(k) = a; 24 | 25 | %% 四点脉冲信号 26 | L1 = 4; 27 | h = ones(L1,1)/4 -------------------------------------------------------------------------------- /rayleigh channel simulation/test_signal_FFT.m: -------------------------------------------------------------------------------- 1 | %% x=0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t), 采样频率fs=100Hz,分别绘制N=128、1024点幅频图 2 | % fs=100Hz,Nyquist频率为fs/2=50Hz。整个频谱图是以Nyquist频率为对称轴的。 3 | % 并且可以明显识别出信号中含有两种频率成分:15Hz和40Hz。 4 | % 由此可以知道FFT变换数据的对称性。因此用FFT对信号做谱分析, 5 | % 只需考察0~Nyquist频率范围内的福频特性。若没有给出采样频率和采样间隔, 6 | % 则分析通常对归一化频率0~1进行。另外,振幅的大小与所用采样点数有关, 7 | % 采用128点和1024点的相同频率的振幅是有不同的表现值,但在同一幅图中, 8 | % 40Hz与15Hz振动幅值之比均为4:1,与真实振幅0.5:2是一致的。 9 | % 为了与真实振幅对应,需要将变换后结果乘以2除以N。 10 | 11 | 12 | %对信号采样数据为128点的处理 13 | clf; 14 | fs = 100; 15 | N = 128; %采样频率和数据点数 16 | n = 0:N-1; 17 | t = n/fs; %时间序列 18 | 19 | x=0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); %信号 20 | 21 | y = fft(x,N); %对信号进行快速fourier变换 22 | mag = abs(y); %求得Fourier变换后的幅值 23 | 24 | f = n*fs/N; %频率序列 25 | 26 | subplot(2,2,1); %绘出随频率变化的振幅 27 | plot(f,mag*2/N); 28 | xlabel('Frequency/Hz'); 29 | ylabel('Amplitude');title('N=128');grid on; 30 | 31 | subplot(2,2,2); 32 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前随频率变化的振幅 33 | xlabel('Frequency/Hz'); 34 | ylabel('Amplitude');title('N=128');grid on; 35 | 36 | 37 | %对信号采样数据为1024点的处理 38 | fs=100; 39 | N=1024; 40 | n=0:N-1; 41 | t=n/fs; 42 | 43 | x=0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); %信号 44 | 45 | y=fft(x,N); %对信号进行快速Fourier变换 46 | mag=abs(y); %求取Fourier变换的振幅 47 | f=n*fs/N; 48 | 49 | subplot(2,2,3),plot(f,mag*2/N); %绘出随频率变化的振幅 50 | xlabel('Frequency/Hz'); 51 | ylabel('Amplitude');title('N=1024');grid on; 52 | 53 | subplot(2,2,4) 54 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前随频率变化的振幅 55 | xlabel('Frequency/Hz'); 56 | ylabel('Amplitude');title('N=1024');grid on; 57 | 58 | -------------------------------------------------------------------------------- /rayleigh channel simulation/test_signal_FFT2.m: -------------------------------------------------------------------------------- 1 | % 例2:x=0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t),fs=100Hz,绘制: 2 | % (1)数据个数N=32,FFT所用的采样点数NFFT=32; 3 | % (2)N=32,NFFT=128; 4 | % (3)N=136,NFFT=128; 5 | % (4)N=136,NFFT=512。 6 | 7 | 8 | % 结论: 9 | % (1)当数据个数和FFT采用的数据个数均为32时,频率分辨率较低,但没有由于 10 | % 添零而导致的其他频率成分。 11 | % (2)由于在时间域内信号加零,致使振幅谱中出现很多其他成分,这是加零造成的。 12 | % 其振幅由于加了多个零而明显减小。 13 | % (3)FFT程序将数据截断,这时分辨率较高。 14 | % (4)也是在数据的末尾补零,但由于含有信号的数据个数足够多,FFT振幅谱也基本不受影响。 15 | % 16 | % 对信号进行频谱分析时,数据样本应有足够的长度,一般FFT程序中所用数据点数与原含有 17 | % 信号数据点数相同,这样的频谱图具有较高的质量,可减小因补零或截断而产生的影响。 18 | 19 | 20 | clc; 21 | clear; 22 | fs = 100; 23 | Ndata = 32; 24 | N = 32; %FFT的长度 25 | n = 0:Ndata-1; 26 | t = n/fs; %数据对应的时间序列 27 | 28 | x = 0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); 29 | 30 | y = fft(x,N); 31 | mag = abs(y); 32 | f = (0:N-1)*fs/N; 33 | 34 | subplot(2,2,1); 35 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前的振幅 36 | xlabel('F/Hz');ylabel('Amplitude'); 37 | title('Ndata=32 Nfft=32');grid on; 38 | 39 | Ndata = 32; 40 | N = 128; %FFT的长度 41 | n = 0:Ndata-1; 42 | t = n/fs; %数据对应的时间序列 43 | 44 | x = 0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); 45 | 46 | y = fft(x,N); 47 | mag = abs(y); 48 | f = (0:N-1)*fs/N; 49 | 50 | subplot(2,2,2); 51 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前的振幅 52 | xlabel('F/Hz');ylabel('Amplitude'); 53 | title('Ndata=32 Nfft=128');grid on; 54 | 55 | Ndata = 136; 56 | N = 128; %FFT的长度 57 | n = 0:Ndata-1; 58 | t = n/fs; %数据对应的时间序列 59 | 60 | x = 0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); 61 | 62 | y = fft(x,N); 63 | mag = abs(y); 64 | f = (0:N-1)*fs/N; 65 | 66 | subplot(2,2,3); 67 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前的振幅 68 | xlabel('F/Hz');ylabel('Amplitude'); 69 | title('Ndata=136 Nfft=128');grid on; 70 | 71 | 72 | Ndata = 136; 73 | N = 512; %FFT的长度 74 | n = 0:Ndata-1; 75 | t = n/fs; %数据对应的时间序列 76 | 77 | x = 0.5*sin(2*pi*15*t)+2*sin(2*pi*40*t); 78 | 79 | y = fft(x,N); 80 | mag = abs(y); 81 | f = (0:N-1)*fs/N; 82 | 83 | subplot(2,2,4); 84 | plot(f(1:N/2),mag(1:N/2)*2/N); %绘出Nyquist频率之前的振幅 85 | xlabel('F/Hz');ylabel('Amplitude'); 86 | title('Ndata=136 Nfft=512');grid on; 87 | -------------------------------------------------------------------------------- /rayleigh channel simulation/test_signal_FFT_phase.m: -------------------------------------------------------------------------------- 1 | %% 相位谱 2 | % 例子: x = sin(2*pi*60*t); 3 | clc; 4 | fs = 1024; 5 | N = 10240; 6 | n = 0:N-1; 7 | t = n/fs; 8 | x = sin(2*pi*60*t); 9 | 10 | y = fft(x,N); 11 | A = abs(y); 12 | f = n*fs/N; 13 | ph = 2*angle(y(1:N/2)); 14 | 15 | ph = ph*180/pi; 16 | subplot(2,1,1) 17 | plot(f(1:N/2),ph(1:N/2)); 18 | xlabel('F/Hz'); 19 | ylabel('phase'); 20 | title('phase spectrum'); 21 | grid on; 22 | 23 | -------------------------------------------------------------------------------- /rayleigh channel simulation/test_signal_power.m: -------------------------------------------------------------------------------- 1 | clear; 2 | Fs=1000; %采样频率 3 | n=0:1/Fs:1; 4 | %产生含有噪声的序列 5 | xn=cos(2*pi*40*n)+3*cos(2*pi*100*n)+randn(size(n)); 6 | window=boxcar(length(xn)); %矩形窗 7 | nfft=1024; 8 | [Pxx,f]=periodogram(xn,window,nfft,Fs); %直接法 9 | subplot(2,2,1); 10 | plot(f,10*log10(Pxx)); 11 | 12 | clear; 13 | Fs=1000; %采样频率 14 | n=0:1/Fs:1; 15 | %产生含有噪声的序列 16 | xn=cos(2*pi*40*n)+3*cos(2*pi*100*n)+randn(size(n)); 17 | nfft=1024; 18 | cxn=xcorr(xn,'unbiased'); %计算序列的自相关函数 19 | CXk=fft(cxn,nfft); 20 | Pxx=abs(CXk); 21 | index=0:round(nfft/2-1); 22 | k=index*Fs/nfft; 23 | plot_Pxx=10*log10(Pxx(index+1)); 24 | subplot(2,2,2); 25 | plot(k,plot_Pxx); 26 | 27 | clear; 28 | Fs=1000; 29 | n=0:1/Fs:1; 30 | xn=cos(2*pi*40*n)+3*cos(2*pi*100*n)+randn(size(n)); 31 | nfft=1024; 32 | window=boxcar(100); %矩形窗 33 | window1=hamming(100); %海明窗 34 | window2=blackman(100); %blackman窗 35 | noverlap=20; %数据无重叠 36 | range='half'; %频率间隔为[0 Fs/2],只计算一半的频率 37 | [Pxx,f]=pwelch(xn,window,noverlap,nfft,Fs,range); 38 | [Pxx1,f]=pwelch(xn,window1,noverlap,nfft,Fs,range); 39 | [Pxx2,f]=pwelch(xn,window2,noverlap,nfft,Fs,range); 40 | plot_Pxx=10*log10(Pxx); 41 | plot_Pxx1=10*log10(Pxx1); 42 | plot_Pxx2=10*log10(Pxx2); 43 | subplot(2,2,3); 44 | plot(f,plot_Pxx); 45 | subplot(2,2,4); 46 | plot(f,plot_Pxx1); 47 | figure(2) 48 | plot(f,plot_Pxx2); 49 | clc; -------------------------------------------------------------------------------- /rayleigh channel simulation/untitled.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangpu03/wireless-communication/bd21bae57305e2d4d1fe04331892465debadafb3/rayleigh channel simulation/untitled.slx --------------------------------------------------------------------------------