MATLAB Answers

How to get value of X based on a specific value of Y in Graph

5 views (last 30 days)
ayinas
ayinas on 27 Oct 2020
Commented: ayinas on 27 Oct 2020
How to get value of X based on a specific value of Y in Graph
for example
x = [ 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 ];
y= [ -77.4236 -91.4051 -105.387 -119.368 -133.35 -147.331 -161.313 -175.294 -189.276 -203.258 ]
and i have to find at what value of x i m getting y value of 100 or any negative value of Y.

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 27 Oct 2020
x100 = interp1(y, x, 100, 'linear', 'extrap')

  7 Comments

Show 4 older comments
ayinas
ayinas on 27 Oct 2020
Sir i m getting answer of x for any positive value of y, like the way (mentioned below) u told me,
x100 = interp1(y, x, 100, 'linear', 'extrap')
but when i m taking negative value of y then m getting an error that index must be a positive interger or logical .
x-100 = interp1(y, x, -100, 'linear', 'extrap')
can u please share the syntax for any negative value of y?
Walter Roberson
Walter Roberson on 27 Oct 2020
The left hand side should be a variable name that does not have to include the number. For example you could assign to xinterp or to x_at_negative_100

Sign in to comment.

More Answers (0)

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by