s = sprintf('format',A,...)
num2str
, int2str
, and sprintf
all convert numbers to their MATLAB string representations and can be used for labeling and titling plots with numeric values.
s = sprintf('format',A,...)
formats the data in matrix A
(and in any additional matrix arguments) under control of the specified format
string and returns it in the MATLAB string variable s
.
sprintf
is the same as fprintf
except that it returns the data in a MATLAB string variable rather than writing it to a file. See fprintf
for full information on creating format strings.
S = sprintf('rho is %6.3f',(1+sqrt(5))/2)
produces the string
S = 'rho is 1.618'
fprintf
,int2str
,num2str
,sscanf
(c) Copyright 1994 by The MathWorks, Inc.