Plotting a %of time vs %of area graph
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/881920/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/881925/image.jpeg)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/882545/image.png)
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.
0 Kommentare
Antworten (1)
KSSV
am 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']);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!