MATLAB: Using fprintf, how to print 1.234D+02 instead of 1.234E+02

fprintf

I'd like to print scientific notations into a file, in the format of FORTRAN. For example, I want to print 1.234D+02 instead of 1.234E+02 into the file. How to realize it? Thank you all~

Best Answer

EDIT
As said before, Stephen's answer is the way to go and I had previously posted an erroneous answer. Second try:
mag = @(x) floor(log10(abs(x)));
val = @(x) x./10.^mag(x);
x = [-25, -0.0001, 0, 0.00025, 1.005, 15, 12345];
leftVal = val(x);
leftVal(isnan(leftVal)) = 0;
rightVal = mag(x);
rightVal(rightVal == -Inf | rightVal == Inf) = 0;
sprintf('%.3fD%+03d\n',[leftVal;rightVal])
Related Question