How to calculate occurrence in percentage?

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 Kommentare

Jing
Jing am 7 Mär. 2013
I'm not quite understand your question. What you asked is the percentage of s4>=0.2 ?
Ara
Ara am 7 Mär. 2013
Yes, I want to plot the percentage occurrence of s4>=0.2 vs time.
Jing
Jing am 7 Mär. 2013
So the problem is plotting or calculating?
Ara
Ara am 7 Mär. 2013
To calculate the occurrence of s4>=0.2 one way is, total number of events(s4>=0.2) observed at one day for all 24 hrs divided total number of events (s4>=0.2) in specific time (1hr, 2 hr...24hrs)*100. In this way I want to know if there is preferred time of day when they occur. So I do not know how to write the code and then plot it.
Walter Roberson
Walter Roberson am 7 Mär. 2013
What is expected in your "r" variable? What are you expecting in your "time" variable?
Ara
Ara am 7 Mär. 2013
"r" represent the data as a GPS week so have to convert it to time and time will give me time in hrs.So, the plot (time,s4) provide the variations of s4(integer) vs time. I put the data in this link; could you please look at it.
Walter Roberson
Walter Roberson am 7 Mär. 2013
What would be the calculation to allow you to calculate the time of day ?
Ara
Ara am 7 Mär. 2013
Bearbeitet: Ara am 7 Mär. 2013
"time" is already calculated in this code and will give me a column data in one minute but when I plot time I defined the range between 0-24hrs. I want to calculate how many percent of the events(s4>=0.2) occurred at time=1,2....hrs(length of time).
Walter Roberson
Walter Roberson am 7 Mär. 2013
Bearbeitet: Walter Roberson am 7 Mär. 2013
Could you confirm that the second column is (seconds since the beginning of the "GPS week", plus 24 hours worth of seconds), and thus the first entry in the file is 1 minute into the "GPS week" ?
If so then why is the maximum value equivalent to 24 hours rather than equivalent to 7 days of 24 hours ?
Should the counts for 24:00 be included in hour 0, or in hour 23, or a count of its own?
Ara
Ara am 7 Mär. 2013
Bearbeitet: Ara am 7 Mär. 2013
Column 2 is look like this; GPS TOW is a constant value "172860" will repeated in all column 2. Each file defined for one day it means my file named 1608_1, "1" represent the day of weak where for second day 1608_2 so in time calculation should change 1 to 2 and so on till 7 day of week and then the file again change to 1. So because of that we have 24 hours instead of 7 days. time=(r./3600)-24*day of weak; Should be included 0-24hrs, but I should have said this time is UT so have to add 8 to convert to LT. Also I want to observe just daytime so I do not want "time between 10-22UT".
Walter Roberson
Walter Roberson am 7 Mär. 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 ?
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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Mär. 2013

1 Stimme

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 Kommentare

Ara
Ara am 7 Mär. 2013
This one is not match with the plot(time, s4). In this plot s4 increase at time 5-10 to 0.35 but the code you wrote at time 22 just increase to 0.5 while based on my analysis I saw some satellites with value more than 0.2 and I expected to show. Is it possible to plot vs time as already calculated to may see it?
First thing to cross-check is
plot(mod(time_minus_one, 86400) / (60*60), 0.2 <= s4(:))
but that might be too crowded to use, so you might want to examine find(0.2 <= s4(:))
Ara
Ara am 7 Mär. 2013
Bearbeitet: Ara am 7 Mär. 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 am 8 Mär. 2013
Bearbeitet: Ara am 11 Mär. 2013
I choose another data and your code work correctly for that. So, thank you very much and sorry for the late acceptance.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by