MATLAB Answers

Why am I getting the error that the 'dimensions of arrays concatenated are not consistent'?

11 views (last 30 days)
Shayma Al Ali
Shayma Al Ali on 27 Jan 2021
Edited: VBBV on 27 Jan 2021
I have a list of DOY numbers that also contain the hours and minutes that I want to convert to datetime. The variable is DOYfilt and has size 1408x1. On the 434th number in the loop, matlab gives me an error: 'Error using vertcat: Dimensions of arrays being concatenated are not consistent.'. What would be going on in the loop that would cause this when it was working beforehand?
for i=1:length(DOYfilt)
date=datestr(DOYfilt(i) + datenum('2012/01/01'));

Answers (1)

VBBV on 27 Jan 2021
Edited: VBBV on 27 Jan 2021
%f true
u10_date=[u10_date date];
By default the arrays are in columns in MATLAB. So as loop increments are done the array increments are being done in rows in your case. Try the above

Community Treasure Hunt

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

Start Hunting!