【发布时间】:2016-01-26 15:44:11
【问题描述】:
如何自动选择矩阵的列向量,其中元素子集中的标量值与同一子集的预定义目标向量中的标量值最接近?
【问题讨论】:
-
显示一些带有示例输入和预期输出的代码。谢谢!
-
“最接近”是什么意思? L1 还是 L2 范数?
标签: matlab matrix vector linear-algebra minimization
如何自动选择矩阵的列向量,其中元素子集中的标量值与同一子集的预定义目标向量中的标量值最接近?
【问题讨论】:
标签: matlab matrix vector linear-algebra minimization
我解决了这个问题并在 100,10 矩阵上测试了方法,它有效 - 也应该适用于更大的矩阵,同时希望不会变得过于计算昂贵
%% Selection of optimal source function
% Now need to select the best source function in the data matrix
% k = 1,2,...n within which scalar values of a random set of elements are
% closest to a pre-defined goal vector with the same random set
% Proposed Method:
% Project the columns of the data matrix onto the goal vector
% Calculate the projection error vector matrix; the null space of the
% local goal vector, is orthogonal to its row space
% The column holding the minimum error vector is the optimal column
% [1] find the null space of the goal vector, containing the projection
% errors
mpg = pinv(gloc);
xstar = mpg*A;
p = gloc*xstar;
nA = A-p;
% [2] the minimum error vector will correspond to the optimal source
% function
normnA = zeros(1,n);
for i = 1:n
normnA(i) = norm(nA(:,i));
end
minnA = min(normnA);
[row,k] = find(normnA == minnA);
disp('The optimal source function is: ')
disp(k)
【讨论】: