Borrar filtros
Borrar filtros

how to find value of y from a graph with a known x value

6 visualizaciones (últimos 30 días)
Ross Hanna
Ross Hanna el 12 de Ag. de 2017
Comentada: Ross Hanna el 13 de Ag. de 2017
Hi There
I already have another question up on this subject but i think i may be over-complicating what i'm trying to ask. In the file i have attached, i have a graph that i have plotted from the data in the worksheet. what i am trying to do is find for values of x, not limited to the data i have, find the corresponding y values. after some reading i think i would have to use interp1, but that came with some issues when i tried to implement it (The grid vector must contain unique points' error and then 'Vectors must be the same lengths') and also use index. would i have to interpolate first to get numbers in incrementys of 1 or 2 etc then use index=find?
thanks, Ross

Respuesta aceptada

Chad Greene
Chad Greene el 12 de Ag. de 2017
Hi Ross,
The data you provide make a multi-valued function. There are several possibly y values for any given x value, so interp1 would not be a valid way to get an answer. Even if you flip the x and y, it's still multi-valued.
Depending on your application, you might be able to think of each x value and each y value as functions of distance along the path. The distance along the path would be something like
d = [0;cumsum(hypot(diff(x),diff(y)))];
Then if you want to get the points xi,yi at some distance di, it would be
xi = interp1(d,x,di);
yi = interp1(d,y,di);
  1 comentario
Ross Hanna
Ross Hanna el 13 de Ag. de 2017
im relatively new to matlab, and trying to execute this is problematic. if i import my data e.g. Force and Velocity, then type in your code, it comes up as "undefined function or variable 'di'". What should i set di equal to? if i set it equal to say 400N it says
Error using griddedInterpolant The grid vectors must contain unique points.
Error in interp1 (line 161) F = griddedInterpolant(X,V,method);
do i have to set it equal to a point in the data i have?
what i am trying to do is write a code that i can give it any value from 1-1400 for example and it will give me the y values associated with them and then i can average them. i looked at your other answer using the scatstat1 function but i dont know if i have to download a file that has it in for example?
Thanks for your reply

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Directed Graphs en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by