Reputation: 185
This is the code along with the output.
>> syms x
>> y=-(x-2*sin(x))/(1-2*cos(x))
y =
(x - 2*sin(x))/(2*cos(x) - 1)
>> x=1.9
x =
1.9000
>> subs(y)
ans =
-(2*sin(19/10) - 19/10)/(2*cos(19/10) - 1)
I can't figure out why this absurd answer is coming. I am not able to fix it.
So far I have tried taking y
also as a symbolic variable and using int(ans)
, with no success. I have also tried storing ans
in a non-symbolic variable, but the same output shows up every time.
Upvotes: 2
Views: 1010
Reputation: 1
eval(subs(...)) also work. I don't know what is better to use eval either double, my teacher uses double
Upvotes: 0
Reputation: 1868
subs
will substitute the value in your expression, but it will stay symbolic and will not be computed. In order to get the value numerically you need eval
instead of subs
.
Upvotes: 0