Plotting a %of time vs %of area graph

2 views (last 30 days)
Ricardo Duarte
Ricardo Duarte on 2 Feb 2022
Answered: KSSV on 3 Feb 2022
Dear all,
I strugglIeling with this problem for a while already. I have the matrix A(1000x1000x120) which represents noise levels arranged as (longitude x latitude x time). This matrix has the following representation (the figure considers time=1, which mean A(1000 x 1000 x 1)). Note that the (1000 x 1000) locations are distributed in an uniform grid.
Im interested in what percentage of time and what percentage of area exceeded a specified level, let's say 150 in order to draw the following plot:
With this plot, I can see what percentage of area exceeds a specif level for what percentage of time.
This is the best I get so far:
which is clearly wrong.
This is my code:
threshold = 150; %limite maximo de ruido
percentageofareavector=[];
for i=1:120
tooNoisy = noise(:,:,i) >= threshold;
soma=sum(sum(tooNoisy)); %soma dos valores que excedem o limiar definido
totalnumberofpoints=(size(tooNoisy,1).*size(tooNoisy,2));
percentageofarea=soma*100/totalnumberofpoints;
percentageofareavector=[percentageofareavector percentageofarea];
end
timevector=1:size(noise,3);
percentageoftime=timevector*100/size(noise,3);
figure; area(percentageoftime, percentageofareavector);
xlabel('% of time'); ylabel('% of area');
title(['% of time vs % of area ', num2str(threshold),'dB is exceeded']);
What am I doing wrong?
Thank you in advance.

Answers (1)

KSSV
KSSV on 3 Feb 2022
I did nothing but removed the loop and tried to make code clearer.
threshold = 150; %limite maximo de ruido
[m,n,p] = size(noise) ;
data = reshape(noise,m*n,p) ; % make 3D a 2D vector
tooNoisy = data >= threshold; % get the logical indices obeying
percentageofarea = sum(tooNoisy)*100/(m*n);
percentageoftime = (1:p)*100/p;
figure; area(percentageoftime, percentageofareavector); % you need to think about this line use area? or histogram?
xlabel('% of time'); ylabel('% of area');
title(['% of time vs % of area ', num2str(threshold),'dB is exceeded']);

Products

Community Treasure Hunt

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

Start Hunting!