How to find the two Y values for my function with one known X value? please help

2 views (last 30 days)
Basically I'm having lots of trouble creating code that could give me the two y values that could coorespond to one x avlue i have.
My x value is 2. I have a function thats a circle that i stored and plotted like,
f=@(x,y)2*x*y - 6*y - 6*x + 4*x^2 + 6*y^2 - 12;
fimplicit(f)
I have two y values when x=2
I tried using the find function -----> index = find(x == 2)
but am only getting back one y value instead of two?
I search up all other examples on matlab answers but nothing is helping :(
  2 Comments
Star Strider
Star Strider on 30 Oct 2019
When I run your code (after inserting the requisite multiplication operators, omitted in ‘f’), it plots a parabola.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 30 Oct 2019
Edited: John D'Errico on 30 Oct 2019
There must be a million ways. Here is a trivial one.
f=@(x,y)2x*y - 6*y - 6*x + 4*x^2 + 6*y^2 - 12;
syms Y
Ysol = solve(f(2,Y))
Ysol =
-1
4/3
By the way, the function you showed had illegal syntax. You need to write 2*x, not 2x.
  1 Comment
Katherine
Katherine on 30 Oct 2019
Thanks John! would it be possible to have matlab simplify this number to a decimal instead of a fraction ?

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!