📄 orthproj.m
字号:
function y = orthproj(A,B)%ORTHPROJ Orthogonal projection onto a subspace.%% ORTHPROJ(A,B) projects the row vectors of matrix A onto the subspace% spanned by the row vectors of matrix B. %% Usage:% Y = orthproj(A,B)%% Inputs: % A := Matrix with n rows and m columns.% B := Matrix with k rows and m columns.% % Outputs: % Y := A*B'*pinv(B*B')*B. Matrix with n rows and m columns.% % See also COORPROJ, PINV.%% CUED System Identification Toolbox.% Cambridge University Engineering Department.% Copyright (C) 1998-2002. All Rights Reserved.% Version 1.00, Date: 01/06/2002% Created by H. Chen and E.C. Kerrigan. colA = size(A,2);colB = size(B,2);if colB ~= colA, error('The column numbers of the two input matrices are not equal.')end% find the bases of the row space of Bk = rank(B);[s,v,d] = svd(B);d = d';B = d(1:k,:); clear d%y = A*(B'/colB)*pinv(B*B'/colB)*B;y = A*B'*pinv(B*B')*B;% *** last line of orthproj.m ***
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -