I am looking for numerical integration with matlab. I know that there is a trapz function in matlab but the precision is not good enough. By searching it online, I found there is a quad function there it seems only accept symbolic expression as input. My data is all discrete and one-dimensional. Is that any way to use quad on my data? Thanks.
Share
An answer to your question would be no. The only way to perform numerical integration for data with no expression in Matlab is by using the
trapzfunction. If it’s not accurate enough for you, try writing your own quad function as Li-aung said, it’s very simple, this may help.Another method you may try is to use the powerful Curve Fitting Tool
cftoolto make a fit then use theintegratefunction which can operate oncfitobjects (it has a weird convention, the upper limit is the first argument!). I don’t think you will get much accurate answers thantrapz, it depends on the fit.