How to find the area from a Positive and negative signal plot
13 views (last 30 days)
Show older comments
Facing problem to find the positive and negative signal area.
- want to find the how many signals has in the positive and negative area seperately. Suppose, for first negative area showing in the plot it might be 46525 discrete signals. but its difficult to find manually everytime. Is there any way ? I can find the the positive and negative discret values only. But want to find positive and negative area seperately. Marked the 7 areas in the attched figure.
- attached the signal file in xlsx format and a figure of the plot,as the mat file storage is high. Tried with the below mentioned code, but can't proceed more.
clear all;
clc;
A= readmatrix('Data.xlsx');
t=1:length(A);
time=t';
power=A(1:end,:);
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Zero-Crossing Indices Of Argument Vector
zeroaxes = zci(power);
gt0 = power>0;
posareaonly = cumtrapz(time(gt0), power(gt0));
negareaonly = cumtrapz(time(~gt0), power(~gt0));
0 Comments
Accepted Answer
KSSV
on 12 Dec 2021
A = readmatrix('Data.xlsx');
t = (1:length(A))' ;
% Positive Area
Ap = A ;
Ap(A<=0) = 0 ;
trapz(t,Ap)
3 Comments
More Answers (1)
Image Analyst
on 12 Dec 2021
To count number of positive and negative regions:
[labeledRegionsPos, numPositive] = bwlabel(power > 0);
[labeledRegionsNeg, numNegative] = bwlabel(power < 0);
Requires bwlabel() which is in the Image Processing Toolbox.
5 Comments
Image Analyst
on 14 Dec 2021
trapz integrates the area under the curve. It does not count the areas like you asked for: "want to find the how many signals"
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!