Getting different outputs from indexing and graphically.How do I verify this indexing value?..
2 次查看(过去 30 天)
显示 更早的评论
clear all
close all
clc
L=10;
n=1.45;
Omega=1.020663297455751e+11;
GAMMAb=3.590391604102621e+08;
c=2.9979e8;
dt=6e-12; %time increment
T=10*2*L*n/c; %total time
fmax = 1e9; %maximun frequency
%fs=80*fmax;
TA=-T/2:dt:T/2; %time axis for the signal
fs=1/dt; %sampling frequency
%t = (-T/2/dt:1:T/2/dt)*dt;
Nt=round(T/dt);
vsine = 1;
phi = vsine*sin(2*pi*fmax*TA);
EL1t=1.274e7*exp(1i*phi); %signal
plot(TA,(EL1t));
%FA = ((0:Nt-1)-floor(Nt/2))/Nt*fs;
FA = (-Nt/2:Nt/2-1)/Nt*fs; %frequency axis
FP=fft(phi); %fft of the signal
%fs=1/dt/Nt;
figure;
Z=plot(FA,fftshift(abs(fft(EL1t/Nt)))); %fft plot with frequency axis
xlim([(Omega/2/pi-GAMMAb/2/pi/2) (Omega/2/pi+GAMMAb/2/pi/2)])
freqlim1=dsearchn(FA',(Omega/2/pi-GAMMAb/2/pi/2))
freqlim2=dsearchn(FA',(Omega/2/pi+GAMMAb/2/pi/2))
FA1=freqlim1:freqlim2;
freqlim=dsearchn(FA',Omega/2/pi)
Y1=fftshift(abs(fft(EL1t(freqlim)/Nt))) %value of the signl at Omega
I have been trying the index of the signal corresponding to frequency at Omega.Graphically it is around 197 and when i substitute the index number in the fft expression , it is showing around 79.
Is this the case of indexing gone wrong??...
0 个评论
采纳的回答
Paul
2024-5-6
L=10;
n=1.45;
Omega=1.020663297455751e+11;
GAMMAb=3.590391604102621e+08;
c=2.9979e8;
dt=6e-12; %time increment
T=10*2*L*n/c; %total time
fmax = 1e9; %maximun frequency
%fs=80*fmax;
TA=-T/2:dt:T/2; %time axis for the signal
fs=1/dt; %sampling frequency
%t = (-T/2/dt:1:T/2/dt)*dt;
Nt=round(T/dt);
vsine = 1;
phi = vsine*sin(2*pi*fmax*TA);
EL1t=1.274e7*exp(1i*phi); %signal
%plot(TA,(EL1t));
%FA = ((0:Nt-1)-floor(Nt/2))/Nt*fs;
FA = (-Nt/2:Nt/2-1)/Nt*fs; %frequency axis
FP=fft(phi); %fft of the signal
%fs=1/dt/Nt;
figure;
Z=plot(FA,fftshift(abs(fft(EL1t/Nt)))); %fft plot with frequency axis
xlim([(Omega/2/pi-GAMMAb/2/pi/2) (Omega/2/pi+GAMMAb/2/pi/2)])
freqlim1=dsearchn(FA',(Omega/2/pi-GAMMAb/2/pi/2))
freqlim2=dsearchn(FA',(Omega/2/pi+GAMMAb/2/pi/2))
FA1=freqlim1:freqlim2;
freqlim=dsearchn(FA',Omega/2/pi)
At this point, freqlim is a single number
EL1t(freqlim)
So its fft
Y1=fftshift(abs(fft(EL1t(freqlim)/Nt))) %value of the signl at Omega
is simply
abs(EL1t(freqlim))/Nt
Are you trying to find the value of the FFT of EL1t at the frequency closest to Omega? Or something else?
2 个评论
Paul
2024-5-6
To find the value of the FFT of EL1t at the frequency closest to Omega, wouldn't that just be (untested)
Y1 = fftshift(abs(fft(EL1t/Nt))));
Y1(dsearchn(FA',Omega/2/pi))
If EL1t is truly finite duration (i.e., not periodic), then you can use freqz to evaluate its Discrete Time Fourier Transform at any frequencies you want (check the doc, you have to query for at least two frequencies).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!