stdsslct.m

来自「偏最小二乘算法在MATLAB中的实现」· M 代码 · 共 31 行

M
31
字号
function [specsub,specnos] = stdsslct(spec,nosamps)
%STDSSLCT Selects subset of spectra for use in standardization
% Selects a subset of the given spectra based on leverage for
% use in developing transforms for instrument standardization.
% The inputs are the available spectra (spec) and the number
% samples to be selected (nosamps). The outputs are the matrix
% of spectra selected (specsub) and the sample numbers of the
% selected spectra (specnos). The I/O format is:
% [specsub,specnos] = stdsslct(spec,nosamps);

% Copyright
% Barry M. Wise
% 1994
[ms,ns] = size(spec);
r1 = mncn(spec);
subset = zeros(1,nosamps);
for i = 1:nosamps
  hat = r1*r1';
  [x subset(1,i)] = max(diag(hat));
  r0 = r1(subset(1,i),:);
  r1(subset(1,i),:) = zeros(1,ns);
  for j = 1:ms
    r1(j,:) = r1(j,:) - ((r0*r1(j,:)')/(r0*r0'))*r0;
  end
end
disp('The subset selected consists of the following samples:')
disp('  ')
disp(subset)
specnos = subset;
specsub = spec(subset,:);

⌨️ 快捷键说明

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