How to find input data that best matches given output data
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2017 年 1 月 23 日
@Jan -- I believe those are Luki just giving us numerical values for the variables above for context...so fs would be 1E10, etc., ...
採用された回答
dpb
2017 年 1 月 25 日
- f=[freq(1):100000:freq(end)].'; % if want fixed df between ranges use colon instead of linspace
- ix=interp1(f1,1:length(f1),freq,'nearest'); % to find closest to given freq in vector f1
Answers for 2. above...
>> [ix f1(ix)/1E6 freq/1E6 f1(ix)-freq]
ans =
1.0e+05 *
0.1122 0.1070 0.1070 -2.4080
0.1176 0.1121 0.1121 -1.6353
0.1230 0.1172 0.1172 -0.3994
0.1283 0.1224 0.1224 0.3734
0.1337 0.1275 0.1275 1.6093
>>
0 件のコメント
その他の回答 (1 件)
Lateef Adewale Kareem
2017 年 1 月 23 日
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');
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!