This is probably what you wanted to write:
fid = fopen('Sample1.xls','wt');
fprintf(fid,'Date \t V1 \t V2 \t V3 \t V4\n');
V2006 = [Y2006, V1_2006, V2_2006, V3_2006, V4_2006];
fprintf(fid,'%d \t %f \t %f \t %f \t %f \n',V2006);
fclose(fid);
V2006 = [Y2006, V1_2006, V2_2006, V3_2006, V4_2006];
t = array2table(V2006, 'VariableNames', {'Date', 'V1', 'V2', 'V3', 'V4'});
writetable(t, 'Sample1.txt', 'Delimiter', '\t');
Best Answer