Do you need the redirection of the table object? You can create the CSV-file directly:
T = { 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h'; ...
3.19 0.25 67.1 66.7 70.3 13.0 45.0 55.2; ...
3.11 0.92 63.4 65.0 69.5 15.2 27.5 36.0};
fid = fopen(FileName, 'w');
if fid == -1, error('Cannot open file: %s', FileName); end
nCol = size(T, 2);
fmt = repmat('%s, ', 1, nCol);
fmt(end-1:end) = '\n';
fprintf(fid, fmt, T{1, 1:nCol});
fmt = repmat('%.2f, ', 1, nCol);
fmt(end-1:end) = '\n';
Data = cell2mat(T(2:end, :)).';
fprintf(fid, fmt, Data);
fclose(fid);
Best Answer