matlab function to find a similar signal in data

7 ビュー (過去 30 日間)
Georges
Georges 2022 年 5 月 20 日
コメント済み: Jan 2022 年 5 月 25 日
I need to find a function that when i give it a signal, gives back the best analog to it.
In different words, take a reference point and find in the data the location of the closest point with the same value. Then take the second point after the reference point and see if the one we found first has a following point similar to this second one, and repeat till the end of the signal we gave.
The function 'findsignal' is not good for me because it doesn't take into consideration the amplitude, it just looks at the similarity of the signal i give and the one it finds.
  11 件のコメント
Georges
Georges 2022 年 5 月 24 日
I am sorry I forgot to add them before, here are the two functions needed
Jon
Jon 2022 年 5 月 24 日
編集済み: Jon 2022 年 5 月 24 日
I was now able to run your code, but unfortunately I can't readily follow from what you have provided what it is exactly you are trying to do and what it is that isn't working. It would be very helpful if you could use your code to produce just one, simple example, with a vector of values representing your "data" and another shorter vector of values representing your "signal" and the indices in the data vector which should be assigned as the location where the signal best matches the data.

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

回答 (1 件)

Jan
Jan 2022 年 5 月 23 日
編集済み: Jan 2022 年 5 月 23 日
Do you want to get something like this:
x = rand(1, 10000);
y = x(300:400) + (rand(1, 101) -0.5) * 0.01; % A small part with some noise
[match, dist] = dullFindSignal(x, y)
match = 300
dist = 0.0294
function [m, dist] = dullFindSignal(x, y)
x = x(:).';
y = y(:).';
nx = numel(x);
ny = numel(y);
nd = nx - ny + 1;
d = zeros(nd, 1);
for k = 1:nd
v = x(k:k + ny - 1) - y;
d(k) = v * v.'; % same as: sum(v .* v)
end
[dist, m] = min(d);
dist = sqrt(dist);
end
  2 件のコメント
Georges
Georges 2022 年 5 月 24 日
I posted the code I am using, could you take a look at it please.
Jan
Jan 2022 年 5 月 25 日
@Georges: Where did you post which code? I do not see it.
I made a suggestion already. It would be useful and polite to tell me, if this solves your needs or what the difference between my suggestion and your wanted result is. Simply ignoring my suggestion does not motivate me to search for some code you have posted anywhere.

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

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by