Return a value in csv data at a specific point
Mostrar comentarios más antiguos
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 comentario
Mathieu NOE
el 17 de Feb. de 2023
hello
have you started a code ?
have data (csv) file to share ?
Respuestas (2)
Krishna
el 20 de Feb. de 2023
0 votos
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.
Try this —
T1 = array2table([sort(randi(1E+4, 12,1)) rand(12,1)*1E+3], 'VariableNames',{'Distance','Depth'})
Dep = interp1(T1.Distance, T1.Depth, 5945)
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.
.
Categorías
Más información sobre Variables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
