Using multiple integration methods in one script
3 views (last 30 days)
Hi, I have to calculate an integral using the midpoint, trapezoid, and simpson's methods. I already have the functions stored in one file in Matlab, but I am encountering difficulty when trying to use them all in one script. I have the integral (sqrt(4-x^2)) saved in a function (called Func). These three methods each call Func. I would appreciate any hints or tips that anyone can give me. THIS IS A SCHOOL ASSIGNMENT, SO NO COMPLETE ANSWERS. Here is my script (eventually, N will contain an array of numbers):
%Approximating an Integral using multiple methods
fprintf('%s | %s | %s | %s \n','N','Method','Value','AbsError')
David Hill on 1 Feb 2020
I would pass Func to your integration functions. You will get answers back (m,t,s) from each of your functions that you can compare to the actual evaluation of the actual integral.