%% Specify Formatted Text as String Array
% To return formatted text as a string, specify formatSpec as a string instead of a character vector when you call the sprintf function.
% Starting in R2017a, you can create strings using double quotes. Convert data and return the result as a string.

formatSpec = "The current time is: %d:%d %s";
A1 = 11;
A2 = 20;
A3 = 'a.m.';
str = sprintf(formatSpec,A1,A2,A3)

%
% Convert input string. Input arrays that contain text either can be character vectors or strings.

A1 = 2;
A2 = 35;
A3 = "p.m.";
str = sprintf(formatSpec,A1,A2,A3)

% Copyright 2012 The MathWorks, Inc.