Plotting a %of time vs %of area graph

2 ビュー (過去 30 日間)
Ricardo Duarte
Ricardo Duarte 2022 年 2 月 2 日
回答済み: KSSV 2022 年 2 月 3 日
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.

回答 (1 件)

KSSV
KSSV 2022 年 2 月 3 日
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']);

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by