How to calculate occurrence in percentage?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2013-3-7
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 ?
采纳的回答
Walter Roberson
2013-3-7
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!