The problem "Subscripted assignment dimension mismatch"?

hi all,
I want to make for loop which count the date and time for each month in one year (2009) To make all of date time values in one column
Year=2009;
Month=1:12;
for i=1:size(Month);
SD(i) = datenum(Year,Month,1,0,0,0);
ED(i) = datenum(Year,Month+1,1,0,0,0)-(1/24);
end
But I get this error
Subscripted assignment dimension mismatch.
What does it mean!
thank you for the helping time

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 26 日

0 投票

Your Month is a vector. datenum(Year,Month,1,0,0,0) needs to be a vector because Month is a vector. You try to store that vector result into a single location.

5 件のコメント

Lilya
Lilya 2015 年 10 月 26 日
pardon Walter what do you mean by "try to store that vector result into a single location"?
Stephen23
Stephen23 2015 年 10 月 26 日
@lina se: the indexing that you use ED(i) refers to one element of ED, in particular the i-th element. A date vector has multiple elements. It is not possible to fit multiple numeric elements into one element of a numeric array.
This is covered in the introductory tutorials, which you should consider revising:
Lilya
Lilya 2015 年 10 月 26 日
ok thank you
Walter Roberson
Walter Roberson 2015 年 10 月 26 日
My guess is you want
SD(i) = datenum(Year,Month(i),1,0,0,0);
and the corresponding change to ED
Lilya
Lilya 2015 年 10 月 28 日
Thank you for your response Mr. Walter

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMarine and Underwater Vehicles についてさらに検索

タグ

質問済み:

2015 年 10 月 26 日

コメント済み:

2015 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by