www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FormatNumbersIntoStringsExample.m

    %% Format Numbers into Strings
% Format |pi| to eight decimal places and return it as a string.
A = pi

%%
formatSpec = string('%.8f')
%%
str = compose(formatSpec,A)

%%
% Create a numeric array that contains values of |pi| and |e|. Use the |%e|
% and |%f| operators with different precisions.
A = [pi exp(1)]

%%
formatSpec = string('The value of pi is %.2e; the value of e is %.5f.');
str = compose(formatSpec,A)