How to pick a set of data close to one another

조회 수: 2 (최근 30일)
jon markl
jon markl 2019년 5월 29일
답변: dpb 2019년 5월 29일
I would like to automate the process of choosing the data series that are withing a range close to the overall data line (black line in figure). Is there a way to do this in MATLAB? Below is the picture of my 21 data series and I am only interested in the series that are close to it. The process I have to do to pick them out is trial-and-error, but I would like to develop a code that could find the series that are within 2 orders of magnitude at any given point of the overall. Any suggestions?

채택된 답변

dpb
dpb 2019년 5월 29일
Is the reference fixed/known a priori, computed from the overall dataset...???
Presuming the former above and is xref, and other data is array x, the "deadahead" way would be something like:
dist=100; % difference limit
[r,c]=size(x); % I'll presume data are by column; transpose or flip logic if not
ix=false(c,1); % none satisfied yet...just preallocated, will write in loop
for i=1:c
d=abs(x(:,i)-xref); % the point-by-point differences
ix(i)=(min(d)<=dist); % logical vector of those within
end
xsave=x(:,ix); % save ones inside distance
Actually, it became clear it's easy enough w/o the loop, too...
d=abs(x-xref); % relies on automagic vector expansion (I think this works, haven't learned all the nuances yet)
ix=any(d<=dist,1);
xsave=x(:,ix);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by