How do I find the value closest to my desired value in a vector

1 vue (au cours des 30 derniers jours)
Yogesh
Yogesh le 6 Mai 2024
Modifié(e) : Matt J le 6 Mai 2024
L=10;
n=1.45;
c=2.9979e8;
dt=6e-12; %time increment
Omega=1.020663297455751e+11;
GAMMAb=3.590391604102621e+08;
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);
FA = (-Nt/2:Nt/2-1)/Nt*fs %frequency axis
FA = 1x161224
1.0e+10 * -8.3333 -8.3332 -8.3331 -8.3330 -8.3329 -8.3328 -8.3327 -8.3326 -8.3325 -8.3324 -8.3323 -8.3322 -8.3321 -8.3320 -8.3319 -8.3318 -8.3317 -8.3316 -8.3315 -8.3314 -8.3313 -8.3312 -8.3311 -8.3310 -8.3309 -8.3307 -8.3306 -8.3305 -8.3304 -8.3303
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
How do I find a value closest to ftreqlims in frequency axis.
freqlims=Omega/2/pi-GAMMAb/2/pi
frqlims = 1.6187e+10

Réponses (1)

Matt J
Matt J le 6 Mai 2024
Modifié(e) : Matt J le 6 Mai 2024
interp1(FA,FA, freqlims,'nearest')

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