Comparing Two Data to find best match

조회 수: 6 (최근 30일)
Curious Mind
Curious Mind 2020년 3월 17일
편집: Aghamarsh Varanasi 2020년 3월 26일
Hello,
I have 2 sets of data, Y and X. Y data is a single column and X contains multiple columns. X & Y have different lengths. Each row in X (columns C-L) is a sample on its on. In other words, all the variables in each row of X (columns C-L) belongs to one sample. As you can see in the attached file, there are 12 Y data and hence I want to extract the corresponding X data (12 of them) that will match well with Y. So I want to take the first value in Y, perform some sort of matching analysis all rows of X to see which one give the least error of matching or some sort of distance. After A value in X has been found that matches well with the first value in Y, either by distance or by some other methods, I want that X row to be replaced with NaN so that it wont be selected again. The procedure will be repeated on all the remaining Y values. I also want the indices or row number of the each of the selected X data to that of the Y so that I can extract them latter. Any suggestions?
Thank you!

답변 (1개)

Aghamarsh Varanasi
Aghamarsh Varanasi 2020년 3월 20일
Hi,
I understand that you are trying to process the data x and y. Let us consider the data is stored in list y and matrix x. And we also have a function that does the matching analysis and returns the best possible row in x, that matches the value in y.
The following algorithm may help you
% Data is extracted into lists x and y
selectedRows = zeros(length(y));
for ii = 1:length(y)
yElement = y(ii);
% Function that returns the selected row in data x
% by performing matching analysis
xRow = getBestMachingRow(yElement,x);
% replace xRow with nan
x(xRow,:) = nan;
% store the row
selectedRows(ii) = xRow;
end
  댓글 수: 2
Curious Mind
Curious Mind 2020년 3월 25일
Hi sorry for the late reply and thank you for your help. I do have a question though: I am getting an error “unrecognized function or variable’getBestMachingRow’.
Any thoughts?
Thank you.
Aghamarsh Varanasi
Aghamarsh Varanasi 2020년 3월 26일
편집: Aghamarsh Varanasi 2020년 3월 26일
getBestMachingRow() is the function that will do the computation to get the best row for a value in y. This function is to be defined according to the requirement. As you where not certain about the matching analysis, I left it as an empty function.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by