Fast Look-up table

6 ビュー (過去 30 日間)
T
T 2015 年 2 月 26 日
回答済み: dpb 2015 年 2 月 26 日
Good morning, I have a long array signal with values x. Now for each of those values x I want to find the closest fit in another array pvalues and return the index. At the moment I am doing it like this:
for a=1:1:length(signal)
tempp=pvalues-abs(signal(a));
[c index1] = min(abs(tempp));
%do stuff with index1
end
But this takes a lot of time (hours)! If I comment all lines and only iterate through the array signal, it is done in 3 seconds. So the problem is finding the index1 value.
Any ideas how to solve this quickly?
Thank you!

回答 (1 件)

dpb
dpb 2015 年 2 月 26 日
[~,idx]=min(pdist2(pvalues,abs(signal),'euclidean'));

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by