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.
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Translated by
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.