How do I stop the loop from overwriting JtD2017?

1 view (last 30 days)
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 Comments
VBBV
VBBV on 29 Nov 2022
Sorry, @Image Analyst suggestion is correct. your input files have several missing data formats (in patches) for datetime column.
VBBV
VBBV on 29 Nov 2022
Edited: VBBV on 29 Nov 2022
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

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 29 Nov 2022
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.

Categories

Find more on Dates and Time in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!