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

Katherine

### Katherine (view profile)

님이 질문을 제출함. 30 Oct 2019
최근 활동 Katherine

### Katherine (view profile)

님이 댓글을 추가함. 30 Oct 2019
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 :(

Star Strider

### Star Strider (view profile)

30 Oct 2019
When I run your code (after inserting the requisite multiplication operators, omitted in ‘f’), it plots a parabola.
Katherine

### Katherine (view profile)

30 Oct 2019
wow my mistake i pasted the wrong function. I edited the right one now

로그인 to comment.

R2019a

## 답변 수: 1

John D'Errico

### John D'Errico (view profile)

님의 답변 30 Oct 2019
John D'Errico

### John D'Errico (view profile)

님이 편집함. 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.

Katherine

### Katherine (view profile)

30 Oct 2019
Thanks John! would it be possible to have matlab simplify this number to a decimal instead of a fraction ?

로그인 to comment.

Translated by