MATLAB: Format colorbar using engineering notation

colorbarformat stringMATLABscientific notation

How can I set the scale of a color bar to use exponential notation, with all exponents being a multiple of 3?
I know that format shortEng will set the format I want for values printed to the Command Window, but I cannot find anything to format string printed elsewhere using this format.

Best Answer

Try this:
engstr = @(x) [x(:).*10.^(-3*floor(log10(abs(x(:)))/3)) 3*floor(log10(abs(x(:)))/3)];
Q1 = logspace(-3, 3, 7);
Result2 = sprintfc('%.4fe%+04d', engstr(Q1))
Alternatively, use compose instead of sprintfc to create the tick labels for the color bar.
Experiment with the format string to get the result you want. This is just an example.