MATLAB: Faster way of using fprintf

fprintf

If I have a large cell array say 10×26 where the first two columns are strings and the remaining columns are all numbers. Instead of having to write fprintf(1,'%s\t%s\t%f\t… and so on) is there a faster method which involves not having specify all of the fixed point notations.

Best Answer

You might try using REPMAT to specify one format for the numeric data that you repeat for the number of numbers you have. For example:
myData = {'a','b',1,2,3,4};
fSpec = repmat('%f\t',1,size(myData,2)-2);
fprintf(1,['%s\t%s\t' fSpec], myData{:})