integration problem

2 views (last 30 days)
Kelly
Kelly on 17 May 2012
Answered: mohan krishna on 15 Feb 2023
I need to integrate f(x)*cos(x)dx for x from 0 to 2*pi.
For f(x), I have a list of 33 y-values with corresponding x=[0:2*pi/32:2*pi].
How do I integrate this in MATLAB?

Answers (2)

Walter Roberson
Walter Roberson on 17 May 2012
trapz(x,y .* cos(x))

mohan krishna
mohan krishna on 15 Feb 2023
integral phi/2 0 cosxdx

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!