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

    %% Replace Only Values in Specified Variables  
% Replace instances of |Inf| and |'N/A'| occurring in specified variables
% of a table with the standard missing value indicators.
%%
% Create a table containing |Inf| and |'N/A'| to represent missing values.
a = {'alpha';'bravo';'charlie';'';'N/A'};
x = [1;NaN;3;Inf;5];
y = [57;732;93;1398;Inf];

A = table(a,x,y)  

%% 
% For the variables |a| and |x|, replace instances of |Inf| with |NaN| and
% |'N/A'| with the empty character vector, |''|. 
B = standardizeMissing(A,{Inf,'N/A'},'DataVariables',{'a','x'}) 

%%
% |Inf| in the variable |y| remains unchanged because |y| is not included
% in the |'DataVariables'| name-value pair argument.