Available under Creative Commons-ShareAlike 4.0 International License.
Determine the value of the following integral:
- Initialize variable x as a row vector, from 0 with increments of pi/100 to pi:
- x=0:pi/100:pi;
- Declare variable y as y=sin(x);
- Issue the following command to calculate the first area, the output will be as follows:
area1=trapz(x,y) area1 = 1.9998
let us increase the increments as above:
x=0:pi/1000:pi; y=sin(x); area2=trapz(x,y) area2 = 2.0000
- 瀏覽次數:1199