My piecewise function becomes NaN
Mostrar comentarios más antiguos
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 comentarios
R.G.
el 31 de Ag. de 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
el 1 de Sept. de 2019
Adam Danz
el 1 de Sept. de 2019
See walter's answer to understand why you're getting a NaN and see his comment(s) under his answer.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Performance and Memory en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!