matlab function to find a similar signal in data
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jon
le 24 Mai 2022
Modifié(e) : Jon
le 24 Mai 2022
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.
Réponses (1)
Jan
le 23 Mai 2022
Modifié(e) : Jan
le 23 Mai 2022
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)
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 commentaires
Jan
le 25 Mai 2022
@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.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!