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
VBBV 2022-11-29
Sorry, @Image Analyst suggestion is correct. your input files have several missing data formats (in patches) for datetime column.
VBBV
VBBV 2022-11-29
编辑:VBBV 2022-11-29
I wonder why you still get the same error. It seems you are converting data to table and then back to array data. May be you need to check dimensions of variables when the data is reformatted during conversions

请先登录,再进行评论。

回答(1 个)

Image Analyst
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.

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by