Solving parametric equations, fplot returning error " Input must be a function handle or symbolic function"

Hey there, trying to knock away at math problems on my own using MATLAB (since my college kinda just throws us in head first), and I am running into an issue. I have to convert a parametric equation to cartesian form, something easy enough on paper, but I am still having trouble with MATLAB and its syntax.
Here is my code:
syms t
syms x
syms y
eq = y == cos(t)
sol_t = solve(eq,t)
eq = y == 3 + sin(t)
eq = subs(eq,t,sol_t)
axis equal
f(x) = eq(1)
fplot(f(x),[0,pi])
I think the problem is that at the end f(x) ends up becoming "f(x) = y == ..." but I don't know how to remove the y == part.

Answers (1)

Hi,
problably you look for this:
syms y
eq1 = y == cos(t)
sol_t = isolate(eq1,t)
eq2 = y == 3 + sin(t)
eq2 = y == subs(rhs(eq2),t,rhs(sol_t))
axis equal
fplot(rhs(eq2),[-pi,pi])
gives:
eq1 =
y == cos(t)
sol_t =
t == acos(y)
eq2 =
y == sin(t) + 3
eq2 =
y == (1 - y^2)^(1/2) + 3
Note that:
>> sin(acos(y)) + 3
ans =
(1 - y^2)^(1/2) + 3
plotted:
Best regards
Stephan

Categories

Asked:

on 26 Sep 2018

Edited:

on 26 Sep 2018

Community Treasure Hunt

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

Start Hunting!