📄 pcpred.m
字号:
function [pred,impact]=pcrpred(x,c,tx,ty,n)
%
% predicts system output given the coefficients
% of the principal components, and the number
% of components to include.
%
% MUST BE GIVEN SCALED DATA
%
%
% Build correct sized set of coefficients
%
cs=c(:,1:n);
%
% calculate the principal components
%
pcs=tx*cs;
size(pcs);
%
% calculate the regression vector
%
a=inv(pcs'*pcs)*pcs'*ty;
%
% Calculate the output
%
pred=x*cs;
pred=pred*a;
%
% Now calculate the impact of each variable
% (ie its overall regression vector
%
[D L]=size(x);
impact=zeros(1,L);
for i = 1:L
for j = 1:n
impact(i)=impact(i)+cs(i,j)*a(j);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -