how to plot no of events ?

1 回表示 (過去 30 日間)
pruth
pruth 2015 年 11 月 9 日
コメント済み: pruth 2015 年 11 月 9 日
hi,
i have a mat file(28762*2), in which first column is for date-time with some time interval for duration of 2012 to 1015. and another column is my data where some values are NAN values. here i want a simple bar plot; month vs no. of events.
here m attaching a sample plot. i want the same plot with my data....hope u understand
  2 件のコメント
Walter Roberson
Walter Roberson 2015 年 11 月 9 日
Should the entries that are NaN be included or excluded from the counting?
pruth
pruth 2015 年 11 月 9 日
編集済み: pruth 2015 年 11 月 9 日
no ..we dont want NAN . it should be excluded from counting

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 9 日
ExcludeIt = isnan(YourData(:,2));
OkayDates = YourData(~ExcludeIt,1);
Okay_vec = datevec(OkayDates);
minyear = min(Okay_vec(:,1));
idx = (Okay_vec(:,1)-minyear) * 12 + Okay_vec(:,2); %year and month
counts = accumarray(idx(:), 1);
numentry = size(counts,1);
bar_dates = datenum([minyear * ones(numentry,1), (1:numentry).', ones(numentry,1)]);
bar(bar_dates, counts)
datetick('x', 'mmm YYYY')
  5 件のコメント
Walter Roberson
Walter Roberson 2015 年 11 月 9 日
I need to head to bed as I have been up all night and it is 06:15 here. Explaining everything step by step would take a long time to write up. You should start reading documentation about the routines you do not understand.
pruth
pruth 2015 年 11 月 9 日
ooh ok sorry .... well thank you so much....

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by