Hi everyone, please i need some help !
i have a rectangular pulse i did the FFT it gaves me a sinc forme and i try to make a phase shifting of this pulse, but when i applicate the ifft on my code i get an horrible forme !!! here is my code :
%XXXXXXXXXXXXXXXXXXXXXXXXXX FFT with bilt in function XXXXXXXXXXXXXXXXXXXX
fs=1e+10;
ts=1/fs;
t=[0:ts:(1.6384e-6)-ts];
A=2;
y=A*trapmf(t,[100e-9 105e-9 205e-9 210e-9]);
subplot(2,1,1)
plot(t,y);
grid;
N=length(t); %which is equal to 16384 so pow of 2
%XXXXXXXXXXXXX FFT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Xf=fftshift(fft(y));
f=fs.*(-N/2:N/2-1)/N;
subplot(2,1,2)
stem(f,abs(Xf)/length(y));
title('FFT');
%XXXXXXXXXXXXXXXXXXXXXXXXX PHASE SHIFT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
phi= -100;
ind = 1:numel(Xf)/2; %Postive frequencys
Xf(ind) =abs(Xf(ind)).*exp(1i*angle(Xf(ind))-1i*phi); %// add 1i*phi
ind = numel(Xf)/2+1:numel(Xf); %// upper half (negative frequencys)
Xf(ind) =abs(Xf(ind)).*exp(1i*angle(Xf(ind))+1i*phi); %// subtract 1i*phi
%XXXXXXXXXXXXXXXXXXXXXXXXXX IFFT XXXXXXXXXXXXXXXXXXX
y1=ifft(ifftshift(Xf));
figure(2)
plot(t,real(y1));
grid on;
title('IFFT');

 채택된 답변

Catalytic
Catalytic 2019년 4월 18일

0 개 추천

Is this what you want
Xf=fftshift(fft(y));
f=fs.*((0:N-1) -ceil((N-1)/2))/N;
subplot(2,1,2)
stem(f,abs(Xf)/length(y));
title('FFT');
%XXXXXXXXXXXXXXXXXXXXXXXXX PHASE SHIFT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
phi= -100;
Xf=Xf.*exp(+1i*phi*2*pi*f);
%XXXXXXXXXXXXXXXXXXXXXXXXXX IFFT XXXXXXXXXXXXXXXXXXX
y1=ifft(ifftshift(Xf));
figure(2)
plot(t,real(y1));
grid on;
title('IFFT');

댓글 수: 9

RH ZA
RH ZA 2019년 4월 18일
Yess !!! thank you soo much !!!
a little question please ! if the phi ( phase shift) is a vector i can do the same thing ?
cause my problem is that i want to modelisate a coax cable and the phi is giving by an equation which is depend on the frequency
Thank you again
Catalytic
Catalytic 2019년 4월 18일
Yes, you can do that.
RH ZA
RH ZA 2019년 4월 18일
Thank you, but how can i get the write frequency vector make it in my equation !
Catalytic
Catalytic 2019년 4월 18일
You have f.
RH ZA
RH ZA 2019년 4월 18일
But if i applicate the whole f look at what i get ! and also my equation gives complex numbers
Capture.PNG
Catalytic
Catalytic 2019년 4월 18일
Who besides you would know what phi(f) is supposed to be...?
RH ZA
RH ZA 2019년 4월 18일
편집: RH ZA 2019년 4월 18일
it supposed to do the the same things, just shiftting the pulse, i'm sorry for asking too musch questions !
Catalytic
Catalytic 2019년 4월 18일
No change to the pulse shape? But you can already do that!
RH ZA
RH ZA 2019년 4월 18일
No, just shiftting it, i tried that with your method but no results, should i give all the frequencys to the equations or just the half ? because with all the frequencys the equation gives complex numbers

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2019년 4월 18일

댓글:

2019년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by