Write a MATLAB program to perform the integration of a quarter circle.
3 views (last 30 days)
Show older comments
Write a MATLAB program to perform the integration of this quarter circle (radius = 4 units) using the trapezoid method. Since the equation of a circle is x^2+y^2=r^2 , the equation of the quarter-circle as shown is y= sqrt(r^2-x^2) . Calculate the value of pi by dividing the area of the circle (the integral times four) by the radius squared ( ). Your MATLAB program should prompt the user for the number of increments to be used in the integration and should print out the value of pi to five decimal places.
5 Comments
Walter Roberson
on 12 Nov 2019
Is there a reason you are not using trapz() or cumtrapz() ?
x = linspace(lowlim, uplim, ni);
y = sqrt(16-(x.^2));
now caculate the area in vectorized ways
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!