Getting different outputs from indexing and graphically.How do I verify this indexing value?..
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Paul
am 6 Mai 2024
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 Kommentare
Paul
am 6 Mai 2024
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).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!