My piecewise function becomes NaN
Show older comments
In the function below my integral becomes -inf when b is nonzero.
I think because of that my ans yields NaN instead of 2. How do I solve this problem?
Nz2=@(a,b) ((b==0)*integral(myfun,itta,inf)+(a>0 & b>0)*2)
Ans=Nz2(a,b)
4 Comments
R.G.
on 31 Aug 2019
Hello. As I can see you want to evalute integral numerically with integrand function myfunc(arg) and limits [itta, inf], where itta - is some variable and inf - means infinity. If so, it's not correct because numerical integration implies finite number of operations (in your case matlab must show warning message: 'Reached the limit...').
Could you provide more information about the task?
Shailee Yagnik
on 1 Sep 2019
Adam Danz
on 1 Sep 2019
See walter's answer to understand why you're getting a NaN and see his comment(s) under his answer.
Accepted Answer
More Answers (0)
Categories
Find more on Performance and Memory 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!