Effacer les filtres
Effacer les filtres

How to calculate occurrence in percentage?

5 vues (au cours des 30 derniers jours)
Ara
Ara le 7 Mar 2013
Hi Everybody,
I want to calculate variation of s4>=0.2 occurrence in percentage. To know how many events observed during 0-24 hr then have a comparison in different times and then plot it vs time. Could you please guide me? Here is the code;
clear;clc;close all;
data=xlsread('filename.xls');
data_nozero=find(data(:,3)>30);
newdata=data(data_nozero,:);
data_filterr=find(newdata(:,25)>60);
data_filtered=newdata(data_filterr,:);
elev_cutof20=find(data_filtered(:,6)>=15);
data_cutoff15=data_filtered(elev_cutof20,:);
r=data_cutoff15(:,2);
time=(r./3600)-24*1;
s4r=data_cutoff15(:,8);
s4cor=data_cutoff15(:,9);
s4=sqrt(s4r.^2-s4cor.^2);
  12 commentaires
Walter Roberson
Walter Roberson le 7 Mar 2013
The data file you linked to starts column 2 at 86460, which is 24*60*60 + 60; it ends column 2 at 172800 which is 24*60*60 + 24*60*60. Which disagrees with what you said in it not being a constant value.
Okay, so time=(r./3600)-24*day of week; now, should the minute in which the day rolls over be counted with the previous day or the new day? The data file does not start with time 0 minutes into day 1 (it starts 1 minute in) and the data file ends with 24 hours 0 minutes into day 1. So should the day be considered to run from 00:01 to 24:00, or was there possibly a splitting error and it should have been from 00:00 to 23:59 ?
More generally, should the count for any hour itself be included in the previous hour or in the new one? For example, there is 04:59, 05:00, 05:01, so should the bins be 04:01 - 05:00, 05:01 - 06:00, or should they be 04:00 - 04:59, 05:00 - 05:59 ?
Ara
Ara le 7 Mar 2013
Yes, right on you and I do agree with all you said, actually the receiver calculate like this and we can not change it unless they change the firmware. And if they do I still using those data which comes out with this error.
This one is good one; 04:01 - 05:00, 05:01 - 06:00

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 7 Mar 2013
time_minus_one = time - 60; %adjust exact hours down to previous hour
hourbin = 1 + floor(mod(time_minus_one, 86400) / (60*60));
s4percent = accumarray( hourbin(:), 0.2 <= s4(:), [], @mean ) * 100;
plot(0:23, s4percent);
  4 commentaires
Ara
Ara le 7 Mar 2013
Modifié(e) : Ara le 7 Mar 2013
This one looks better but time is not that one I expected. Time shows occurrence in minutes. I want to show it in hrs and increase value in time between 5-10 as I observed in main code. Otherwise all the previous calculations is become wrong and am not able to justify my results.
Sorry, I am facing another problem as well that I believe you can help me but since I have asked the problem here yesterday so am not sure is ok to state here again or nor.
Anyway, I want to compute *SI=10logs4(t1)/s4(1)*to have signal intensity s4. But the problem is the receiver give me sampling rate 50Hz for s4 while I need to compute SI with sampling rate 1 Hz. Could you please help me?
Ara
Ara le 8 Mar 2013
Modifié(e) : Ara le 11 Mar 2013
I choose another data and your code work correctly for that. So, thank you very much and sorry for the late acceptance.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by