Sym equation to double

조회 수: 14 (최근 30일)
Dallin Porter
Dallin Porter 2021년 2월 15일
댓글: Star Strider 2021년 2월 15일
I have an equation, y == 319.242, saved as a symbolic variable, and want to use this vlaue as a variable, y. How do I convert the symbolic equation to a variable?
Here's what I have so far. I'm probably doing this the worst way possible, so any help is appreciated.
syms y
theta=60;
r=y/sind(theta);
x=r*cosd(theta);
eqn=y==600-x^2/121;
eqn=isolate(eqn,y);
y=vpa(eqn); %This is where I'm stuck. I don't know how to convert the equation to a double to use in the next equation.
x=y*cotd(theta);
x=vpa(x);
scatter(x,y)

채택된 답변

Star Strider
Star Strider 2021년 2월 15일
There are 2 values for ‘y’, so use solve rather than isolate to calculate them:
syms y
theta=60;
r=y/sind(theta);
x=r*cosd(theta);
eqn=y==600-x^2/121;
% eqn=isolate(eqn,y)
eqn = solve(eqn,y)
y=vpa(eqn);
x=y*cotd(theta);
x=vpa(x);
scatter(x,y)
.
  댓글 수: 2
Dallin Porter
Dallin Porter 2021년 2월 15일
Thank you. That's exactly what I needed.
Star Strider
Star Strider 2021년 2월 15일
As always, my pleasure!

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

추가 답변 (1개)

David Hill
David Hill 2021년 2월 15일
theta=60;
fun=@(x)600-(x*cotd(theta))^2/121-x;
y=fsolve(fun,300);
x=y*cotd(theta);
scatter(x,y);

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by