How do I stop the loop from overwriting JtD2017?

1 回表示 (過去 30 日間)
Shiva
Shiva 2022 年 11 月 29 日
回答済み: Image Analyst 2022 年 11 月 29 日
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 Center および File ExchangeDates and Time についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by