MATLAB: Fprintf %f

%f fprintf

I have an fprintf command
fprintf('\n %s \n%0.3f',Data{:})
where my data contains a sentence and then an array. I want the decimal places for the array to only go to 3 which seems only work for every other number. So every thing comes out fine but it looks like this:
Sentence
1.784
2.862691e+000
2.737
2.855501e+000
2.976
i dont want the exponentials

Best Answer

Your format specifier string expects Data to have the form "string number string number string number etc." Apparently Data{1} is a string but I'm not sure Data{3} and Data{5} are. They're probably numbers, not strings, so when it tries to print those numbers out as strings (according to %s) you get the unexpected results. Show us how you constructed Data.