standvec.m

来自「王小平《遗传算法——理论、应用与软件实现》随书光盘」· M 代码 · 共 25 行

M
25
字号
function z = standvec(x)
%
% STANDVEC
%
% Standardises a vector x, ie. the mean of x is
% subtracted from all elements of x and the
% result is divided by the standard deviation of x.
%
% Called: z = standvec(x) 
%
% Only for vectors!

[rows,cols]=size(x);
if cols==1 
   meanx=ones(size(x))*mean(x);
   stdx = std(x);
   z=(x-meanx)/stdx;
else
   disp('Error:')  
   disp('   Only for vectors')
   disp(' ')
end;
clear meanx, stdx;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?