PRÁCTICA 3 RESUELTA + PLOTS (2017)

Pràctica Inglés
Universidad Universidad Politécnica de Cataluña (UPC)
Grado Ingeniería de Aeronavegación - 3º curso
Asignatura Radiolocalització
Año del apunte 2017
Páginas 8
Fecha de subida 03/07/2017
Descargas 2
Subido por

Vista previa del texto

Anna Reig PRÁCTICA 3 MAIN clear all; clear figures; %INPUT % Number % Vector % Vector % Signal of of of to samples per pulse [adim.] chip phases [degrees] chip amplitudes (1 by default) [adim.] noise ratio [dB] %OUTPUT % Samples of the baseband output signal vector without noise % Samples of the baseband output signal vector with noise %% 3.2 + 3.3 SNR=30; % %%%%% K=5 %%%%%%% chip_phases=[0,0,0,180,0]; chip_amplitude=ones(1,length(chip_phases)); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 2(10, chip_phases, chip_amplitude, SNR); %angle--> funció que ens dóna l'angle baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); %plot de les fases plot(baseband_signal_no_noise_phase); hold on; plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Barker code K=5'); %fliplr permet girar el vector de dreta a esquerra h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); %convolució del senyal amb soroll amb el senyal sense soroll! OJO %equival al següent: sabent com són els nostres polsos, si convolucionem el %que ens arriba amb la forma dels nostres polsos, som capaços de detectar el %pic d'amplitud tot i tenir una potència molt reduïda--> la resolució es %manté!!!! --> es pot recuperar info convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (module) (V)'); xlabel('Number of iterations'); title('Matched filter output'); % %%%%% K=7 %%%%%%% chip_phases=[0,0,0,180,180,0,180]; Anna Reig chip_amplitude=ones(1,length(chip_phases)); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 2(10, chip_phases, chip_amplitude, SNR); baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); plot(baseband_signal_no_noise_phase); hold on; plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Barker code K=7'); h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (V)'); xlabel('Number of iterations'); title('Matched filter output'); % %%%%% K=11 %%%%%%% chip_phases=[0,0,0,180,180,180,0,180,180,0,180]; chip_amplitude=ones(1,length(chip_phases)); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 2(10, chip_phases, chip_amplitude, SNR); baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); plot(baseband_signal_no_noise_phase); hold on; plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Barker code K=11'); h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (V)'); xlabel('Number of iterations'); title('Matched filter output'); % %%%%% K=13 %%%%%%% chip_phases=[0,0,0,0,0,180,180,0,0,180,0,180,0]; chip_amplitude=ones(1,length(chip_phases)); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 2(10, chip_phases, chip_amplitude, SNR); baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); plot(baseband_signal_no_noise_phase); hold on; Anna Reig plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Barker code K=13'); h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (V)'); xlabel('Number of iterations'); title('Matched filter output'); %% 3.4 % %%%%% K=13 %%%%%%% SNR=30:-10:-10; chip_phases=[0,0,0,0,0,180,180,0,0,180,0,180,0]; chip_amplitude=ones(1,length(chip_phases)); figure; for(i=1:length(SNR)) [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 2(10, chip_phases, chip_amplitude, SNR(i)); h=conj(fliplr(baseband_signal_no_noise)); convolution=abs(conv(h,baseband_signal_with_noise)); plot(convolution); hold on; ylabel('Baseband output signal amplitude module (V)'); xlabel('Number of iterations'); title('Matched filter output'); end legend('SNR=30dB', 'SNR=20dB', 'SNR=10dB', 'SNR=0dB', 'SNR=-10dB'); %% 3.5 + 3.6 %K=9 SNR=30; K=9; L=sqrt(K); a=(0:L-1); chip_phases=2*pi/L*(a.'*a); chip_phases=reshape(chip_phases, [1,L^2]); chip_amplitude=ones(1,L^2); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 4_frank(10, chip_phases, chip_amplitude, SNR); %angle--> funció que ens dóna l'angle baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); plot(baseband_signal_no_noise_phase); hold on; plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Frank polyphase code K=9'); Anna Reig %fliplr permet girar el vector de dreta a esquerra h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (module) (V)'); xlabel('Number of iterations'); title('Matched filter output'); K=16; L=sqrt(K); a=(0:L-1); chip_phases=2*pi/L*(a.'*a); chip_phases=reshape(chip_phases, [1,L^2]); chip_amplitude=ones(1,L^2); [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal_ 4_frank(10, chip_phases, chip_amplitude, SNR); %angle--> funció que ens dóna l'angle baseband_signal_no_noise_phase=angle(baseband_signal_no_noise); baseband_signal_with_noise_phase=angle(baseband_signal_with_noise); figure; subplot(2,1,1); plot(baseband_signal_no_noise_phase); hold on; plot(baseband_signal_with_noise_phase); legend('baseband output signal without noise', 'baseband output signal with noise'); ylabel('Baseband output signal phase (rad)'); xlabel('Number of iterations'); title('Pulse burst for Frank polyphase code K=16'); %fliplr permet girar el vector de dreta a esquerra h=conj(fliplr(baseband_signal_no_noise)); subplot(2,1,2); convolution=abs(conv(baseband_signal_with_noise, h)); plot(convolution); ylabel('Matched filter amplitude (module) (V)'); xlabel('Number of iterations'); title('Matched filter output'); FUNCTION: baseband_signal_2 function [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal( chip_number, chip_phases, chip_amplitude, SNR) chip_phases=cos(chip_phases*180/pi)+1i*sin(chip_phases*180/pi); equival a e^(-fase*j) % %IDEA DELS CODIS: volem que cada fase duri X numero de chip, per tant si tenim %Imaginem numero de chips 5 %Codi Barker 5 (5 valors diferents) (0 0 0 180 0): %durant 5 iteracions tindrem --> fase 0, durant les 5 seguents->fase 0, les 5 %seguents--> fase 0, les 5 seguents--> fase 180 i les 5 seguents--> fase 0.
Anna Reig %total tindrem numero de iteracions=X numero de chips*numero de valors del codi de barker %QUÈ FA EL FOR? %Imaginem numero de chips 5 %Codi Barker 5 (5 valors diferents) %[de iteracio 1 a numero de chips (que es 5)]=> senyal=primera amplitud*primera fase=1*cos(0graus)=1 %[de iteracio numero de chips+1 (6) a numero de chips*2 (10)]=> senyal=segona amplitud*segona fase=1*cos(0graus)=1 %[de iteracio numero de chips*2+1 (11) a numero de chips*3 (15)]=> senyal=tercera amplitud*tercera fase=1*cos(0graus)=1 %[de iteracio numero de chip*3+1 (16) a numero de chips*4 (20)]=> senyal=quarta amplitud*quarta fase=1*cos(0graus)=1 %[de iteracio numero de chips*4+1 (21) a numero de chips*5 (25)]=> senyal=cinquena amplitud*cinquena fase=1*cos(0graus)=1 for(i=1:length(chip_phases)) baseband_signal_no_noise(chip_number*(i1)+1:chip_number*i)=chip_amplitude(i).*chip_phases(i); end SNR=10^(SNR/10); %Energia=Potència*temps %Energia=Sumatori del quadrat del valor absolut de la senyal Energy_signal=sum(abs(baseband_signal_no_noise).^2); %A partir de l'energia del senyal i del SNR traiem l'energia del soroll Energy_noise=Energy_signal/SNR; %Generem soroll aleatori (amb funció randn) que tingui component real i imaginària amb %longitud igual al numero de fases*numero de chips noise=randn(1,chip_number*length(chip_phases))+1i*randn(1,chip_number* length(chip_phases)); %Normalitzem el soroll amb l'energia del soroll/l'energia soroll random noise_normal=noise.*sqrt(Energy_noise)./sqrt(sum(abs(noise).^2)); %Senyal amb soroll = senyal sense + soroll baseband_signal_with_noise=noise_normal+baseband_signal_no_noise; FUNCTION: baseband_signal_4_frank function [baseband_signal_no_noise,baseband_signal_with_noise]=baseband_signal( chip_number, chip_phases, chip_amplitude, SNR) chip_phases=cos(chip_phases)+1i*sin(chip_phases); fase*j) % equival a e^(- %IDEA DELS CODIS: volem que cada fase duri X numero de chip, per tant si tenim %Imaginem numero de chips 5 %Codi Barker 5 (5 valors diferents) (0 0 0 180 0): %durant 5 iteracions tindrem --> fase 0, durant les 5 seguents->fase 0, les 5 %seguents--> fase 0, les 5 seguents--> fase 180 i les 5 seguents--> fase 0.
%total tindrem numero de iteracions=X numero de chips*numero de valors del codi de barker Anna Reig %QUÈ FA EL FOR? %Imaginem numero de chips 5 %Codi Barker 5 (5 valors diferents) %[de iteracio 1 a numero de chips (que es 5)]=> senyal=primera amplitud*primera fase=1*cos(0graus)=1 %[de iteracio numero de chips+1 (6) a numero de chips*2 (10)]=> senyal=segona amplitud*segona fase=1*cos(0graus)=1 %[de iteracio numero de chips*2+1 (11) a numero de chips*3 (15)]=> senyal=tercera amplitud*tercera fase=1*cos(0graus)=1 %[de iteracio numero de chip*3+1 (16) a numero de chips*4 (20)]=> senyal=quarta amplitud*quarta fase=1*cos(0graus)=1 %[de iteracio numero de chips*4+1 (21) a numero de chips*5 (25)]=> senyal=cinquena amplitud*cinquena fase=1*cos(0graus)=1 for(i=1:length(chip_phases)) baseband_signal_no_noise(chip_number*(i1)+1:chip_number*i)=chip_amplitude(i).*chip_phases(i); end SNR=10^(SNR/10); %Energia=Potència*temps %Energia=Sumatori del quadrat del valor absolut de la senyal Energy_signal=sum(abs(baseband_signal_no_noise).^2); %A partir de l'energia del senyal i del SNR traiem l'energia del soroll Energy_noise=Energy_signal/SNR; %Generem soroll aleatori (amb funció randn) que tingui component real i imaginària amb %longitud igual al numero de fases*numero de chips noise=randn(1,chip_number*length(chip_phases))+1i*randn(1,chip_number* length(chip_phases)); %Normalitzem el soroll amb l'energia del soroll/l'energia soroll random noise_normal=noise.*sqrt(Energy_noise)./sqrt(sum(abs(noise).^2)); %Senyal amb soroll = senyal sense + soroll baseband_signal_with_noise=noise_normal+baseband_signal_no_noise; Anna Reig Anna Reig ...

Comprar Previsualizar