It may be that I'm using MATLAB 2021a version and a fractional exact answer can not be outputted, because running your code on my end still gives the answer as a decimal approximation. I'm also not sure what even, odd functions have to do with spitting out the output.
Actually, your original answer works without using @Walter Roberson line of code, but I wanted to take the integral of the whole region instead of splitting it into half and doubling, if I have functions or areas without identical halves (odd?), I suppose there aren't exact solutions with the version I'm using.
If you have functions or areas that do not have identical halves, then it is unlikely that the function uses abs() [but possible...] int() tends to struggle a bit with abs()
Whether a function without abs() can be integrated or not... depends a lot on the function. It is easy to create functions that have no known exact integral.
if I have functions or areas without identical halves (odd?), I suppose there aren't exact solutions with the version I'm using.
Sometimes it works, sometimes not. The "abs" function is always problematic together with "int". And it doesn't have to do with your MATLAB version - it also doesn't work in R2024b as you can see above.
No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.
Translated by
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.