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

    %% Text and Characters
% When you are working with text, enclose sequences of characters in single
% quotes. You can assign text to a variable.
myText = 'Hello, world';
%%
% If the text includes a single quote, use two single quotes within the
% definition.
otherText = 'You''re right'
%%
% |myText| and |otherText| are arrays, like all MATLAB(R) variables. Their
% _class_ or data type is |char|, which is short for _character_.
whos myText
%%
% You can concatenate character arrays with square brackets, just as you
% concatenate numeric arrays.
longText = [myText,' - ',otherText]
%%
% To convert numeric values to characters, use functions, such as |num2str|
% or |int2str|.
f = 71;
c = (f-32)/1.8;
tempText = ['Temperature is ',num2str(c),'C']