My piecewise function becomes NaN
이전 댓글 표시
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
R.G.
2019년 8월 31일
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
2019년 9월 1일
Adam Danz
2019년 9월 1일
See walter's answer to understand why you're getting a NaN and see his comment(s) under his answer.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!