Length of variable is much shorter during a loop?

조회 수: 3 (최근 30일)
Shayma Al Ali
Shayma Al Ali 2021년 1월 24일
댓글: Stephen23 2021년 1월 24일
I have a variable 'DOYfilt' that has a sizw 1408x1 double. It contains datenums so I have a for loop to convert it to datestrings. When I enter the loop, the length of DOYfilt is only 7. What do I do so that it can go through the entire length of the variable?
for i=1:length('DOYfilt')
date=datestr(DOYfilt(i) + datenum('2012/01/01'),'mm/dd/yyyy HH:MM');
u10_date=[u10_date;date];
end
  댓글 수: 1
Stephen23
Stephen23 2021년 1월 24일
length('DOYfilt')
measures the length of the character vector 'DOYfilt', which has seven characters. Probably you intended to get the lenght of the variable DOYfilt like this:
length(DOYfilt)

댓글을 달려면 로그인하십시오.

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 1월 24일
편집: KALYAN ACHARJYA 2021년 1월 24일
This
length(DOYfilt) % Note here
Not This
length('DOYfilt')
^........'..'

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by