How do I stop the loop from overwriting JtD2017?
1 回表示 (過去 30 日間)
古いコメントを表示
date = EcoTotemBroadwayBicycleCount(:,1);
DateTime = table2array(date);
FMTDate = datetime(DateTime,'InputFormat','MM/dd/yyyy HH:mm:ss a');
CyclistAmt = EcoTotemBroadwayBicycleCount(:,5);
DateNum = datevec(FMTDate);
DateNum(:,7) = [0];
A = table2array(CyclistAmt);
DateNum(:,7) = [A];
%%
idx = DateNum(:,1)==2017;
Year2017 = DateNum(idx,:);
i = 1;
for i = 1:1:12
inx2 = Year2017(:,2)==i;
JtD2017 = Year2017(inx2,:)
JtD2017Cyl =JtD2017(:,7);
MonthlyData2017(i) =sum(JtD2017Cyl);
Med2017(i)= median(JtD2017Cyl);
end
%%
bar(MonthlyData2017)
title('2017 Data')
xlabel('Month')
ylabel('No. of Cyclists')
5 件のコメント
VBBV
2022 年 11 月 29 日
Sorry, @Image Analyst suggestion is correct. your input files have several missing data formats (in patches) for datetime column.
回答 (1 件)
Image Analyst
2022 年 11 月 29 日
For some reason you removed all the comments, as I'm sure were in there as all professional programmers put them in. Maybe you could add the comments back in. But it looks like you are trying to get some kind of group statistics. So for that I'd recommend not doing that loop but use one of the functions: splitapply, groupsummary, or grpstats.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!