How do I stop the loop from overwriting JtD2017?

1 vue (au cours des 30 derniers jours)
Shiva
Shiva le 29 Nov 2022
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 commentaires
VBBV
VBBV le 29 Nov 2022
Sorry, @Image Analyst suggestion is correct. your input files have several missing data formats (in patches) for datetime column.
VBBV
VBBV le 29 Nov 2022
Modifié(e) : VBBV le 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

Connectez-vous pour commenter.

Réponses (1)

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

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by