find a point on a graph

조회 수: 97 (최근 30일)
Jens Petit-jean
Jens Petit-jean 2021년 3월 10일
댓글: Star Strider 2021년 3월 10일
Hello,
How can I find a point on this curve with y=1000, so what is the x-value when y=1000?
Thanks in advance

답변 (2개)

Star Strider
Star Strider 2021년 3월 10일
Try somethiing like this with your data:
x = 10:50; % Create Data
y = 4000 - 80*x; % Create Data
x1k = interp1(y, x, 1000); % Interpolate
figure
plot(x, y, x1k, 1000, 'rs') % Plot Result
xline(x1k, '--k')
yline(1000,'--k')
Use interp1 to find the x-value for the y-value at 1000.
  댓글 수: 2
Jens Petit-jean
Jens Petit-jean 2021년 3월 10일
then how does it work for a system of equations?
function [dy] = FunctieOpdracht10_2_1(t,y)
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = -9.81 + (9.81.*(y(2)).^2)/10000
end
this is what I have
[t,h]=ode23(@FunctieOpdracht10_2_1, [0 60], [4000 0])
plot(t,h)
ylim([0 4000])
Thanks in advance
Star Strider
Star Strider 2021년 3월 10일
You would need to do the same calculation for each curve. That is not a problem if the curves are monotonically increasing or decreasing, however if that is not the situation, it would be necessary to find the index of a point close to the one you want to interpolate, and then select a few points on either side of that index to do the interpolation with. That region would have the curve monotonically increasing or decreasing, satisfying the requirements for interpolation.

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


John D'Errico
John D'Errico 2021년 3월 10일
You COULD approximate the curve with some function. Best to choose one that can be intelligently extrapolate. Then since you need ot find a value of x where y == 1000, you would either invert the function, perhaps using an analytical inverse if one exists, or using fzero.
Or, since this is fairly well behaved looking curve, you could approximate the data in that plot using a model of the form x(y). Now all you need do is evaluate the functino at y==1000.
We don't have your data, nor any clue as to what a reasonable model might be for all of this. So go and do one of the above.

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by