How can I store the places of two different points at two different time?
1 view (last 30 days)
I have to measure a distance between two points. I have to see where the solution across some values quite small, like 0.01. In other words, there should be the first point which is like (x(150), 0.01) at t=150 and the second one should be (x(200), 0.01) at t=200. Distance should be equal (x(200)-x(150)) because y-values are the same.
My problem is that how can I store/ calculate the x(150) and x(200) places when the time reaches to t=150 and t=200, respectively?
I will be very glad if someone can answer my question.
Many thanks in advance.
Elias Gule on 29 Mar 2018
I think this is what you mean: You have a time vector with elements like 150,200,etc,
and a position vector with elements like 0.01,0.01,etc.
If this is true, then I guess the code you that you want is:
t = [150 200 300 400 500]; % replace with your own time vector
x = [0.01 0.01 1 2 5]; % replace with your own position/x vector
t0 = 150; % time for point 1
t1 = 300; % time for point 2
x0 = x(ismember(t,t0));
x1 = x(ismember(t,t1));
dx= x1 - x0; % delta x
dy = 0; % since you said the y-values are always the same
dist = hypot(dx,dy); % the distace between two points