outfile='obs_float/vel_next_all.dat'; ufile='obs_float/unext3d.dat'; vfile='obs_float/vnext3d.dat'; fid=fopen(outfile,'w'); for i=1:36 time_step=i; ubck=load(ufile); vbck=load(vfile); %Check if coordinates are the sames vel_bck=zeros(size(ubck,1),5); vel_bck(:,1)=time_step; vel_bck(:,2)=ubck(:,2); vel_bck(:,3)=ubck(:,3); vel_bck(:,4)=ubck(:,4); vel_bck(:,5)=vbck(:,4); fprintf(fid,'%d %d %d %f %f\n',vel_bck'); end fclose(fid);