How to find value of Y if i know X value from grap

조회 수: 399 (최근 30일)
navi g
navi g 2017년 1월 9일
댓글: Walter Roberson 2020년 4월 29일
i search on matlab searching question but not found it. I have a graph with a curve. I want to know the Y value from my graph example X = 10 to 11, till 10 to 11 in y axis i have to mark. how to find Y?
i also seen some example like this, i can find for one x value one y value, but continues x data how to mark in cureve
%example having only one x data X = 1:0.1:20;
Y = sin(X);
index = find(X==10);
Y_point = Y(index)
% See graphically
plot(X,Y,X(index),Y_point,'o')
my question is now how to mark for x value 10 to 11

채택된 답변

KSSV
KSSV 2017년 1월 9일
편집: KSSV 2017년 1월 9일
clc; clear all ;
X = 1:0.1:20;
Y = sin(X);
index = find(X==10);
Y_point = Y(index)
% See graphically
plot(X,Y,X(index),Y_point,'o')
hold on
% plot X in the range 10 to 11
Xi = X(X>=10 & X<=11) ;
Yi = Y(X>=10 & X<=11) ;
plot(Xi,Yi,'*k')
  댓글 수: 3
afiq hassan
afiq hassan 2020년 4월 25일
But what if I want to find value from x axis and I already know the y axis?
Walter Roberson
Walter Roberson 2020년 4월 29일
[~, idx] = min( abs(Y_values - target_y_value) );
closest_x = X_values(idx);
closed_y = Y_values(idx);

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 1월 9일

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by