Question on using interpolate function
Mostrar comentarios más antiguos
I've the following
x = [1 2 3 4 5 6];
data = [0.1 0.2 0.3 0.4 0.4 0.4];
vq1 = interp1(data,x,0.4)
I want to find the x value at which data has 0.4 (first occurence).
I used interpolate. But the following error occurS
The grid vectors must contain unique points.
Any suggestions on how to proceed when data doesn't contain uniqe values will be helpful
1 comentario
Deepa Maheshvare
el 28 de En. de 2020
Respuestas (2)
KSSV
el 28 de En. de 2020
Use logical indexing:
x = [1 2 3 4 5 6];
data = [0.1 0.2 0.3 0.4 0.4 0.4];
vq1 = x(abs(data-0.4)<10^-5)
1 comentario
Deepa Maheshvare
el 28 de En. de 2020
Editada: Deepa Maheshvare
el 28 de En. de 2020
Bhaskar R
el 28 de En. de 2020
"I want to find the x value at which data has 0.4 (first occurence)."
match_loc = find(data == 0.4);
val = x(x == match_loc(1)); % first occurance of 0.4
1 comentario
Deepa Maheshvare
el 28 de En. de 2020
Categorías
Más información sobre MATLAB 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!