how to plot no of events ?

1 view (last 30 days)
pruth on 9 Nov 2015
Commented: pruth on 9 Nov 2015
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
pruth on 9 Nov 2015
no ..we dont want NAN . it should be excluded from counting

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Nov 2015
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')
pruth on 9 Nov 2015
ooh ok sorry .... well thank you so much....

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by