Reputation: 4408
Say I have the following symbolic function:
syms f(t)
f(t)=sin(t)/t
I want to get the limit using another symbolic function. I tried:
syms lim(x)
lim(x)=limit(f(t),t,x)
But when I tried to use lim(0)
I got this error:
Error using symengine (line 59) Division by zero.
Can this be fixed?
Upvotes: 1
Views: 369
Reputation: 8401
Matlab does not have delayed assignments as discussed here. Therefore, when lim
is created, the call to limit
is immediately evaluated with x
replacing t
:
>> syms t x f(t) lim(x)
>> f(t) = sin(t)/t
f(t) =
sin(t)/t
>> lim(x) = limit(f(t),t,x)
lim(x) =
sin(x)/x
And when you evaluate lim(0)
, you get sin(0)/0
, which throws the error.
Upvotes: 1
Reputation: 36710
Take a look at lim(x)
. For some reason the limit
is gone. I don't really understand what is going wrong there. If you use an anonymous function instead of a function handle, the evaluation of limit
is postponed until x has a value and it works.
>> lim=@(x)limit(f(t),t,x)
lim =
@(x)limit(f(t),t,x)
>> lim(0)
ans =
1
Upvotes: 1