Issues with robustness of integral function? - integrating a constant
Show older comments
I am wondering why:
>> integral(@(t)5, 0, 1)
does not work unless I use:
>> integral(@(t)5, 0, 1, 'ArrayValued', true)
or
>> integral(@(t)5 + 0*t, 0, 1)
Since the function is certainly not (inherently) array-valued, I prefer the latter solution, however I am actually using this with the "matlabFunction" function to turn a symbolic expression into a function handle, and thus it does not work there. Is there something fundamental I should be doing differently?
Closer to how I am doing things:
>> syms t
>> f = 5 + 0*t
>> F = matlabFunction(f, 'Vars', t)
>> want = integral(F, 0, 1)
The reason this is an issue is because I am symbolically differentiating a Hamiltonian to get the equations of motion, and depending on the Hamiltonian, one of the equations of motion could turn out to be constant. I want my code to work cleanly for any input.
Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!