Find nearest point left side of the search reference line

7 vues (au cours des 30 derniers jours)
Ganesh Naik
Ganesh Naik le 15 Juil 2022
Modifié(e) : Ganesh Naik le 15 Juil 2022
I am trying to find points left side of the reference line. I have already stored the required points in a separate array and used both 'desearchn' and 'rangesearch' and 'knnsearch' matlab methods. They all works with 80% efficiency but if the "left side" points are further they tend to pick the "right side" points instead of the left side points from the reference line. My code and data are given below:
As you can see in the image i am expected get yellow and red patches in the order but in few cases they are overlapped this is due to search points detected on the right side instead of the left side. Any help/suggestions are highly appreciated.
close all
load data.mat
%Convert Beg_Ex and Beg_In into realtime values
Beg_Ex1 = Time(Beg_Ex);
Unrecognized function or variable 'Beg_Ex'.
Beg_In1 = Time(Beg_In);
% Find the distance from Beg_Ex to Block1
Beg = Block1(:,1);
End_Cycle11 = dsearchn(Beg_Ex1',Beg);
End_Cycle1 = Beg_Ex1(End_Cycle11); % Expiration Cycle
% First Half Cycle - Pre Apnea
Start_Stop1 = [End_Cycle1' Beg];
% Find the distance from Beg_In to EndCycle1
End_Cycle22 = dsearchn(Beg_In1',End_Cycle1');
End_Cycle2 = Beg_In1(End_Cycle22); %Inspiration Cycle
% Second Half Cycle - Pre Apnea
Start_Stop2 = [End_Cycle2' End_Cycle1'];
plot(Time,Flow,'b');
hold on;
plot(Time(Beg_Ex),Flow(Beg_Ex),'ro','MarkerFaceColor','r','MarkerSize',10)
hold on;
plot(Time(Beg_In),Flow(Beg_In),'go','MarkerFaceColor','g','MarkerSize',10)
grid on
title('Flow')
xlabel('time [s]')
ylabel('flow [a.u.]')
% legend({'flow' 'begIn' 'begExp' })
vfill( Start_Stop1,'r','facealpha',.6,'edgecolor','k','linestyle',':');
hold on;
vfill( Start_Stop2,'y','facealpha',.6,'edgecolor','k','linestyle',':');
  2 commentaires
KSSV
KSSV le 15 Juil 2022
Read about knnsearch
Ganesh Naik
Ganesh Naik le 15 Juil 2022
Modifié(e) : Ganesh Naik le 15 Juil 2022
Ok thanks, I tried knnsearch with "eucleadean" and 'mahalanobis' value methods but no luck.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by