Issues with robustness of integral function? - integrating a constant
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!