Length of variable is much shorter during a loop?

1 Ansicht (letzte 30 Tage)
Shayma Al Ali
Shayma Al Ali am 24 Jan. 2021
Kommentiert: Stephen23 am 24 Jan. 2021
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 Kommentar
Stephen23
Stephen23 am 24 Jan. 2021
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)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Jan. 2021
Bearbeitet: KALYAN ACHARJYA am 24 Jan. 2021
This
length(DOYfilt) % Note here
Not This
length('DOYfilt')
^........'..'

Kategorien

Mehr zu Unit Conversions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by