for iy = 2005:2017 yr = num2str(iy); for im = 1:12 if im < 10 mn = sprintf('0%s',num2str(im)); else mn = num2str(im); end switch im case {1 3 5 7 8 10 12} M_END = 31; case {4 6 9 11} M_END = 30; otherwise %----------------------------------------------------------
% Check whether this is a leap year or not and then assign
% the appropriate month end.
%---------------------------------------------------------- ny = str2num(yr); ly = isequal(floor(ny/4)*4,ny); if ly == 1 M_END = 29; else M_END = 28; end end for id = 1:M_END if id < 10 dy = sprintf('0%s',num2str(id)); else dy = num2str(id); end dt = strcat(yr,mn,dy); ndt = str2num(dt); for ih = 0:6:18 if ih < 10 hr = sprintf('0%s',num2str(ih)); else hr = num2str(ih); end DATES=[]; Date_STR= strcat(dt,hr); Date_num= str2num(Date_STR); end end end end DATES=vertcat(DATES,[Date_num]); fn=sprintf('my_dates.txt'); fid=fopen(fn,'w'); fprintf(fid,'%10.2f\n',DATES'); fclose(fid);
MATLAB: I am creating a date file using the following script, i want it to print DATES[] in the file the_dates.txt but it’s only printing one date which is 2.0171e+09, that is when i type A(1,1)…i pleading for help
fileprint
Best Answer