Getting different outputs from indexing and graphically.How do I verify this indexing value?..

2 Ansichten (letzte 30 Tage)
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));
Warning: Imaginary parts of complex X and/or Y arguments ignored.
%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))
freqlim1 = 96299
freqlim2=dsearchn(FA',(Omega/2/pi+GAMMAb/2/pi/2))
freqlim2 = 96355
FA1=freqlim1:freqlim2;
freqlim=dsearchn(FA',Omega/2/pi)
freqlim = 96327
Y1=fftshift(abs(fft(EL1t(freqlim)/Nt))) %value of the signl at Omega
Y1 = 79.0205
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??...

Akzeptierte Antwort

Paul
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))
freqlim1 = 96299
freqlim2=dsearchn(FA',(Omega/2/pi+GAMMAb/2/pi/2))
freqlim2 = 96355
FA1=freqlim1:freqlim2;
freqlim=dsearchn(FA',Omega/2/pi)
freqlim = 96327
At this point, freqlim is a single number
EL1t(freqlim)
ans = 7.1267e+06 + 1.0560e+07i
So its fft
Y1=fftshift(abs(fft(EL1t(freqlim)/Nt))) %value of the signl at Omega
Y1 = 79.0205
is simply
abs(EL1t(freqlim))/Nt
ans = 79.0205
Are you trying to find the value of the FFT of EL1t at the frequency closest to Omega? Or something else?
  2 Kommentare
Yogesh
Yogesh am 6 Mai 2024
I am trying to find the value of fft of El1t at Omega.
That should be equal to the value shown in the plot.
The value in the plot is around 198 and the indexing value is around 79.
This is what I am not understanding.
Paul
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).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by