필터 지우기
필터 지우기

Finding Corresponding x axis values of a constant curve on Y-axis

조회 수: 7 (최근 30일)
Sandip Ghatge
Sandip Ghatge 2020년 6월 8일
댓글: Sarah Nasra 2023년 1월 1일
Hello,
I have a curve similar to shown below in the image.
I plan to find the 'x' values at which the function 'y' is maximum
I have denoted 'y' by 'cylpressure'
When i write the following,
[y,x] = max(cylpressure);
It returns me values
y = 400000
x= 118
But i need the values of 'x' when y starts to get constant(i.e. at x = 118, which i got from above code) and when y starts dwelling down(i.e at x = 180)
What changes must be done?

답변 (1개)

KSSV
KSSV 2020년 6월 8일
Let (x,y) be your data. Where y is cylpressure Dont use
[y,x] = max(cylpressure);
Rather, use:
[val,idx] = max(cylpressure);
In the baove val gives you maximum value of y and idx gives you index of the maximum value. You can get the respective value of x using x(idx).
If you know the value of x and you want to get corresponding y value use interp1.
yi = interp1(x,y,xi) ;
  댓글 수: 4
Sandip Ghatge
Sandip Ghatge 2020년 6월 8일
Thank you, i guess 'sort' will work. I was aware about findpeaks but i dont have a signal processing toolbox hence did not use it.
Sarah Nasra
Sarah Nasra 2023년 1월 1일
how we can do the opposite? if i know the y value and want to extract the x value?

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by