Finding area of a wave

Hi Assume that, an output of a function(in simulink) is random sine-wave. That random sine-wave is originating at 0 (zero). how can i find out area for the wave above and below origin (Zero). Any logic?
... . . .
. . . . .
. . . . .
. Area1 . . Area3 . .
0________._____._________._____._______
.Area2. . .
. . ...
...

Answers (1)

I don't have Simulink so I'm not sure, but do you have the signal as an array? If so can't you just do
positiveSum = sum(signal(signal>0));
negativeSum = -sum(signal(signal<0));
If you need the areas in each half-cycle, then you'll have to find the zero crossings first.

Asked:

on 27 Feb 2012

Community Treasure Hunt

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

Start Hunting!