orthproj.m
来自「剑桥大学用于线性和双线性动力学系统辨识的工具箱」· M 代码 · 共 42 行
M
42 行
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 + =
减小字号Ctrl + -
显示快捷键?