Reputation:
can anyone tell me how to determine the AUC of the signal shown in the screenshot in Matlab? I would like to determine the AUC above the blue line (demarcation) over the 120 sec. period. Can anyone tell me how to do this in Matlab? Many thanks in advance!
Upvotes: 0
Views: 271
Reputation: 1683
There are a few functions in Matlab to integrate or approximate an integral of a function. Depending on the size of your vector - therefore depending on the sampling rate of that signal - some functions can save you time.
If y
is your signal, x
is the cutoff for the blue line (a single number) and it is positive:
y2 = y-x; % subtract blue line
y2(y2<0) = 0; % set negative values to 0
y2
curve. You can approximate the integral of the signal with the Trapezoidal numerical integration method from matlab -- trapz
function:But you need to know the sampling rate of the original signal to select the length for the specific 120 seconds.
freq = ?; % Sampling rate in Hz
% For 120 seconds:
sampling _length = 120 * freq;
% select the points for the first 120 seconds and approximate the integral
Q = trapz(y2([1:sampling _length]))
If you want to deepen in this topic: https://es.mathworks.com/help/matlab/math/integration-of-numeric-data.html
Upvotes: 1