MATLAB Answers

0

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

Katherine 님이 질문을 제출함. 30 Oct 2019
최근 활동 Katherine 님이 댓글을 추가함. 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 :(

  댓글 수: 2

When I run your code (after inserting the requisite multiplication operators, omitted in ‘f’), it plots a parabola.
wow my mistake i pasted the wrong function. I edited the right one now

로그인 to comment.

태그

제품


릴리스

R2019a

답변 수: 1

John D'Errico 님의 답변 30 Oct 2019
John D'Errico 님이 편집함. 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

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

로그인 to comment.



Translated by