Plotting datapoints with their time distance on x-axis
Show older comments
Hello everyone!
I want to ask something but i'm not sure if iteven possible to do that. I have data that looks like this (only a small part of it):

What my code does is getting the timedifference of each pair (sometimes there are 3 points, sometimes 4, but i'm only interested in the first and last one) and calculates the travelled distance between those points. The result looks like this (the red line is not of interest):

What i'm supposed to do is match the travelled distance to the timepoints above. If I have to describe the expected result, i would say the following: the travelled distance between aprox. 100.5s and 102s is 12cm, after that it is 16cm from 102s till 105s and so on.. I hope you get what I mean.
I attached the needed data in question.mat. To get the plots above i did the following:
load question.mat
r_Trommel = 1;
r_0=0.319;
kmh=15;
figure(1)
plot(t(index_1:index_2-1),Betrag_Ableitung);
hold on
plot(max_XWerte,max_YWerte,'mo');
hold off
k=1;
while (k>=1) && (k<=length(max_XWerte)-3)
if (abs(max_XWerte(k+3)-max_XWerte(k))> 0.05) && (abs(max_XWerte(k+3)-max_XWerte(k))< 0.08)
laenge(k) = abs(max_XWerte(k+3)-max_XWerte(k))*(kmh/3.6);
k = k+4;
elseif (abs(max_XWerte(k+2)-max_XWerte(k))>= 0.03) && (abs(max_XWerte(k+2)-max_XWerte(k))< 0.09)
laenge(k) = abs(max_XWerte(k+2)-max_XWerte(k))*(kmh/3.6);
k=k+3;
else
laenge(k) = abs(max_XWerte(k+1)-max_XWerte(k))*(kmh/3.6);
k=k+2;
end
end
for m=1:length(laenge)
if laenge(m) == 0
laenge(m) = laenge(m-1);
end
end
for f=1:length(laenge)
l_test(f)=100*(2*r_Trommel*asin(laenge(f)/(2*r_Trommel)));
end
x=0:1:length(l_test)-1;
figure(2)
plot(x,l_test)
Thank you in advance!!
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
