how to find points between boundaries
Ältere Kommentare anzeigen
Hi, I have a text file of data points taken from the coordinates of a point at time t and time t+10us, from this I can derive velocity and trajectory, a plot is attached. What I want to do with the data is figure out a way to work on the whole array at once without breaking it down into smaller arrays. The tricky bit is making sure you have the correct drops paired (t,t+10us), I have ways to do this but have not included it in the code below which I wanted to simplify as much as possible.
Plot shows the position of the points and the boundaries plotted between them, the boundaries demarcate something I am calling a 'slice'. So slice1 is empty,slice2 has 2 points,slice3 has 2 points,slice4 has 2 points, etc. What I don't know how to do simply (I found a very convoluted way of doing it) is how to use the vector B in such a way as to identify which points fall within the slice, ideally for anything that falls on or around the dashed boundary I would like to be able to see if it belonged to which of the neighbouring slices, for example if one slice had 2 points and its neighbour only 1 point then the boundary point should belong to slice 2. Any pointers?
Best regards
Steve
clear all
close all
clc
Ax=[1.6 1.2 2.2 2.7 2.4 3.3 3.33 4.8 4.9 5.7 5.1 6.6 6.2]';%simplified and reduced x data
Ay=[0.3 0.7 0.33 0.2 0.64 0.4 0.7 0.35 0.67 0.38 0.61 0.32 0.65]';%simplified and reduced y data
B=[0 1 2 3 4 5 6 7]';
scatter(Ax,Ay,'filled','b')
axis([0 7 0 0.8])
hold on
y1=get(gca,'ylim');
plot([B(:,1),B(:,1)],y1,'--r')
box on;grid minor
xlabel('x coordinates');
ylabel('y coordinates');
print('PointsFigure', '-dpng','-r0');
resultsVars={ 'SliceID','amount_of_points_in_slice','point1_Xcoord','point2_Xcoord','point1_Ycoord','point2_Ycoord',}
2 Kommentare
KSSV
am 12 Mär. 2018
YOu can use <= and >= inequalities to get the indices you want.
Stephen Devlin
am 12 Mär. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!