Index exceeds matrix dimensions

4 次查看(过去 30 天)
Megan Mirkhanian
Megan Mirkhanian 2019-12-18
评论: Ridwan Alam 2019-12-20
char_date_start= char(date_start);
char_date_end = char(date_end);
yearRange = str2num(char_date_start(1:4))+1:1:str2num(char_date_end(1:4));
dateCheck = table(yearRange',zeros(length(yearRange),1),'VariableNames',{'WaterYear','DayCount'});
  1 个评论
Ridwan Alam
Ridwan Alam 2019-12-20
Hi Megan, does the response below work? If yes, please accept the answer.

请先登录,再进行评论。

回答(1 个)

Ridwan Alam
Ridwan Alam 2019-12-19
I tried this, it worked fine. No error:
date_start = "2015-01-01";
date_end = "2019-10-01";
char_date_start= char(date_start);
char_date_end = char(date_end);
yearRange = str2num(char_date_start(1:4))+1:1:str2num(char_date_end(1:4));
dateCheck = table(yearRange',zeros(length(yearRange),1),'VariableNames',{'WaterYear','DayCount'});
What's your date_start and date_end?

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by