필터 지우기
필터 지우기

Return a value in csv data at a specific point

조회 수: 3 (최근 30일)
Jack Lakeman
Jack Lakeman 2023년 2월 17일
답변: Star Strider 2023년 2월 20일
Hiya there,
I've got CSV data containing 2 columns . Colum 1 is Distance and column 2 is Depth.
Im wanting a simple code to find what the Depth value is at Distance = 5945
Thanks in advance
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2023년 2월 17일
hello
have you started a code ?
have data (csv) file to share ?

댓글을 달려면 로그인하십시오.

답변 (2개)

Krishna
Krishna 2023년 2월 20일
You can use the following link to get an idea of how to work with .csv files in MATLAB.
Use the find function mentioned in the doc to get the Depth value at Distance = 5945 after extracting values from csv file using readtable.

Star Strider
Star Strider 2023년 2월 20일
Try this —
T1 = array2table([sort(randi(1E+4, 12,1)) rand(12,1)*1E+3], 'VariableNames',{'Distance','Depth'})
T1 = 12×2 table
Distance Depth ________ ______ 387 660.72 948 177.47 1063 750.46 2557 800.03 3207 812.46 4697 215.64 5233 797.51 6848 324.8 7895 438.41 8677 808.11 8851 328.27 9910 651.15
Dep = interp1(T1.Distance, T1.Depth, 5945)
Dep = 589.1087
figure
plot(T1.Distance, T1.Depth, 'DisplayName','Data')
hold on
plot(5945, Dep, 'rs', 'DisplayName','Interpolated Value')
hold off
grid
xlabel('Distance')
ylabel('Depth')
xline(5945, ':k', 'Distance = 5945')
The reverse is just as straightforward (‘Distance’ as a funciton of ‘Depth’), however one extra step is involved.
.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by