필터 지우기
필터 지우기

Make Matlab search for the closest match to a given pattern within a matrix?

조회 수: 1 (최근 30일)
If I have a data set of something that occurred during a day, for example stored in a 550x1 variable. Could I use it as a target data set to search through a much bigger matrix containing the same type of values but during an entire year, for example a 550x365 matrix and have Matlab tell me where the closest matching (with the same length) pattern occurred? Is there a function for that?
Note that I’m not looking for an exact match, what I’m looking for might not even be even close to a 100% match. But can Matlab identify what would be classified as the closest match? And perhaps even give me some sort of confidence value of how good the match was?

채택된 답변

Star Strider
Star Strider 2015년 3월 17일
If you have the Statistics Toolbox, use the knnsearch function. If you don’t have it, the same algorithm is fairly easy to implement:
M = randi(10, 20, 5); % Search Matrix
T = randi(10, 1, 5); % Search Vector
for k1 = 1:size(M,1)
D(k1) = sqrt(sum((M(k1,:) - T).^2));
end
The index of the lowest value of ‘D’ is the index of the row in ‘M’ that is the closest match to ‘T’.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by