How to find the location of approximately equal value in vector?

12 ビュー (過去 30 日間)
vinod kumar govindu
vinod kumar govindu 2017 年 2 月 3 日
コメント済み: Walter Roberson 2017 年 2 月 10 日
I having Z =10.7000 and ACF(auto correlation function)
ACF =
Columns 1 through 6
0 -1.0000 -1.8478 -2.2678 -2.0719 -1.2071
Columns 7 through 12
0.2242 1.9749 3.6955 5.0000 5.5433 5.0962
Columns 13 through 18
3.6027 1.2071 -1.7549 -4.8033 -7.3910 -9.0000
Columns 19 through 24
-9.2388 -7.9246 -5.1334 -1.2071 3.2856 7.6317
Columns 25 through 30
11.0866 13.0000 12.9343 10.7530 6.6641 1.2071
here i want to find out approximately equal value of Z in ACF and also location of the ACF value. Here the Z value is approximately equal to 10.7530 of ACF and it present at location of ACF(28). Help me to write the code for find approximately equal value of Z in ACF and its location(28).

採用された回答

Stephen23
Stephen23 2017 年 2 月 3 日
編集済み: Stephen23 2017 年 2 月 3 日
You should calculate the absolute differences, and then use min to get the closest value:
>> Z = 10.7000;
>> ACF = [0,-1.0000,-1.8478,-2.2678,-2.0719,-1.2071,0.2242,1.9749,3.6955,5.0000,5.5433,5.0962,3.6027,1.2071,-1.7549,-4.8033,-7.3910,-9.0000,-9.2388,-7.9246,-5.1334,-1.2071,3.2856,7.6317,11.0866,13.0000,12.9343,10.7530,6.6641,1.2071]
>> [~,idx] = min(abs(Z-ACF))
idx =
28
>> out = ACF(idx)
out = 10.753
  13 件のコメント
vinod kumar govindu
vinod kumar govindu 2017 年 2 月 10 日
編集済み: vinod kumar govindu 2017 年 2 月 10 日
I am using MATLAB 7.6.0(R2008a)
and for
syms IRx1 QRx1
also it showing same error
Walter Roberson
Walter Roberson 2017 年 2 月 10 日
It sounds as if you do not have a symbolic toolbox installed, so I do not understand why your earlier code used syms. symsum cannot be used without the Symbolic Toolbox.
It did not make sense to me that you used syms there anyhow.
j = sqrt(-1);
n = 1 : 128;
for i=1:128
this_entry = sum( (IRx1(n) + j.*QRx1(n)) .* (IRx1(n-i) - j.*QRx1(n-i)) );
ACF1(i) = this_entry
end
However, this will have the problem I described before. You are allowing i to exceed n, which is going to lead to negative subscripts.
I suspect your code should look more like
plain = complex(IRx1, QRx1);
for i = 1 : 128
this_entry = sum( plain .* circshift(plain, [1 i]);
ACF1(i) = this_entry;
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by