Effacer les filtres
Effacer les filtres

Phase shifting a Pulse

3 vues (au cours des 30 derniers jours)
RH ZA
RH ZA le 15 Mai 2019
Modifié(e) : RH ZA le 15 Mai 2019
Hi everyone,
please i need some help in my programme, i want to do the FFT of a pulse and then phase shifting every spectrum with his frequency multiplied by 2, i get a forme that its not correct as the teacher showed us last time.
here is my program :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PULSE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fe=1e+8;
te=1/fe;
subplot(2,1,1);
t=[0:te:(1e-6)-te];
A=2;
x=A*trapmf(t,[100e-9 105e-9 205e-9 210e-9]);
plot(t,x);
xlabel ('Temps(s)');
ylabel ('Amplitude(V)');
title ('Pulse de tension');
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%**FFT**%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,1,2);
Xf=fftshift(fft(x));
df=fe/length(x)
f=[-fe/2:df:fe/2-df];
subplot(2,1,2);
stem(f,abs(Xf),'r');
grid on;
xlabel('frequence');
ylabel('X(f)');
%%%%%%%%%%%%%%%%%%%%%%%**Phase shifting**%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ind = 1:numel(Xf)/2; %// lower half (negative frequencys)
phi = 2*f(ind); %/ desired phase shift (i used only the positive frequency, cause with all the vector F i get a matrix deminsions error !!)
Xff(ind) = abs(Xf(ind)).*exp(1i*angle(Xf(ind))+1i*phi); %// add 1i*phi
ind = numel(Xf)/2+1:numel(Xf); %// upper half (positive frequencys)
Xff(ind) = abs(Xf(ind)).*exp(1i*angle(Xf(ind))-1i*phi);
%%%%%%%%%%%%-- IFFT---%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y=ifft(ifftshift(Xff));
figure(2);
plot(t,real(y),'r','linewidth',2);
hold on;
plot(t,x,'linewidth',2);
grid on;
Thank youu!

Réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by