matlab function to find a similar signal in data

조회 수: 12 (최근 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 CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by