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

    %% Construct Valid MATLAB Identifiers Using Specified Replacement Style  

%% 
% Replace invalid characters with the corresponding hexadecimal representation. 
S = {'Item_#','Price/Unit','1st order','Contact'};
N = matlab.lang.makeValidName(S,'ReplacementStyle','hex') 

%%
% In the first and second elements, |makeValidName| replaced the invalid
% characters (|#| and |/|), with their hexadecimal representation. In the
% third element, |makeValidName| appended a prefix because the character vector does not
% begin with a letter, deleted the empty space, and capitalized the character
% following the deleted space.   

%% 
% Delete invalid characters. 
N = matlab.lang.makeValidName(S,'ReplacementStyle','delete') 

%%
% |makeValidName| deleted the invalid characters (|#| and |/|). In the third
% element, |makeValidName| appended a prefix because the character vector does not begin
% with a letter, deleted the empty space, and capitalized the character
% following the deleted space.