How to find input data that best matches given output data
Afficher commentaires plus anciens
f2 = linspace(-fs/2,fs/2,length(x));
f1 = transpose(f2(end/2+1:end));
freq = transpose([10.7e9 11.213e9 11.725e9 12.238e9 12.75e9]);
Given data:
fs/2 = 5e11
length(x) = 1048576
I am looking for the entries of f1 corresponding to all frequencies between min(freq) and max(freq). I was thinking to achieve this with:
find(ismembertol(f1,min(freq),0.0001e+10) ==1);
But this gives the error: "Index exceeds matrix dimensions".
So for example, entries 11219,11220,11221 of f1 are:
- 10698805521,7795 rounded to 1.0699e+10
- 10699759197,0054 rounded to 1.0700e+10
- 10700712872,2314 rounded to 1.0701e+10
So apparently there is no entry of f1 equal to min(freq) = 10.7e9. So, two questions: First: Can I make f1 have frequencies ranging from min(freq) to max(freq) in steps of 0.001e9 just by changing length(x) ? I mean these frequencies have to be within the range of f1, but f1 is also allowed to have smaller and/or higher frequencies.
Second: If there is no such way to achieve my first question, how do I at least find the closest frequencies of f1 corresponding to frequencies between min(freq) and max(freq) ? In the example given, this would be entry 11220 of f1.
Thanks for help!!
4 commentaires
Adam
le 23 Jan 2017
Surely just looking at the result will answer your question immediately?!
Jan
le 23 Jan 2017
The last 3 lines of code are magic. This is no valid Matlab syntax and I cannot guess the puurpose.
dpb
le 23 Jan 2017
@Jan -- I believe those are Luki just giving us numerical values for the variables above for context...so fs would be 1E10, etc., ...
Luki
le 24 Jan 2017
Réponse acceptée
Plus de réponses (1)
Lateef Adewale Kareem
le 23 Jan 2017
I guess this is what you wanted fs/2 = 5e11 length(x) = 958576 freq = transpose([10.7 11.213 11.725 12.238 12.75] e9)
f2 = linspace(-fs/2,fs/2,length(x));
f1 = transpose(f2(end/2+1:end));
you didnt tell us what v is. my guess is v must be of the same dimension as freq and f1 will contain 479289 elements.
if you tell us the error message you are getting we may be able to help interpol_v = interp1(freq,v,f1,'spline');
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!