Finding closest value in data table

조회 수: 10 (최근 30일)
Seungman Kim
Seungman Kim 2020년 12월 8일
편집: KALYAN ACHARJYA 2020년 12월 8일
1) I want load large amount of experiment data (distance for x-axis, velocity for y-axis).
2) Find and load the closest to 1m on the x-axis, and also the corresponding the velocity in y-axis.
3) Find and load the closest to 2m on the x-axis, and also the corresponding the velocity in y-axis.
4) Find and load the closest to 3m on the x-axis, and also the corresponding the velocity in y-axis.
I want to rearrange the experiment data with regular intevals as above.
Please help..
x_distance y_velocity
0.52299 0.000237
1.04598 0.041598
1.56897 0.005755
2.09196 0.012987
2.614949 0.009894
3.137939 0.050168
3.660929 0.00584
4.183919 0.045582
4.706909 0.00007
5.229899 0.054282
5.752889 0.002132
6.275879 2.508755
6.798868 3.193212
7.321858 3.460158
7.844848 3.206859
8.367838 2.923524
8.890828 2.23533
9.413818 1.127799
9.936808 0.429399
10.459798 0.814943

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 12월 8일
편집: KALYAN ACHARJYA 2020년 12월 8일
Hints:
data=[0.52299 0.000237
1.04598 0.041598
1.56897 0.005755
2.09196 0.012987
2.614949 0.009894
3.137939 0.050168
3.660929 0.00584
4.183919 0.045582
4.706909 0.00007
5.229899 0.054282
5.752889 0.002132
6.275879 2.508755
6.798868 3.193212
7.321858 3.460158
7.844848 3.206859
8.367838 2.923524
8.890828 2.23533
9.413818 1.127799
9.936808 0.429399
10.459798 0.814943];
Next: Distance for x-axis, velocity for y-axis
x_distance=data(:,1);
y_velocity=data(:,2);
Next: "Find and load the closest to 1m on the x-axis, and also the corresponding the velocity in y-axis."
What does the 1m menas?
Is that closset between x_distance & y_velocity?? If so, then
close_1m=x_distance-y_velocity;
Then finding the correcponding index
idx=find(close_1m==min(close_1m))
If you are looking for finding close in between in the same array, then you can use diff function
Please do the rest part by yourself.
:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by