📄 weightrows.m
字号:
function Y = weightrows(X,weights)%WEIGHTROWS Weights the rows of a matrix.%%--------%Synopsis:% Y = weightrows(X,weights)%%Description:% Weights each row of the two-dimensional matrix "X" with a weight from% "weights". The same weight is applied to all columns of the same row.% This is equal to% Y = diag(weights)*X%%Output and Input:% Y (CxMatrixT): The output matrix.% X (CxMatrixT): The matrix, whose rows to weight.% weights (CxVectorT): The weights to use. Length of this vector must be% equal to the number of rows in "X".%%--------%Notations:% Data type names are shown in parentheses and they start with a capital% letter and end with a capital T. Data type definitions can be found in [1]% or by "help dbtdata".% [D] = This parameter can be omitted and then a default value is used.% When the [D]-input parameter is not the last used in the call, it must be% given the value [], i.e. an empty matrix.% ... = There can be more parameters. They are explained under respective% metod or choice.%%Examples:%%Software Quality:% (About what is done to ascertain software quality. What tests are done.)%%Known Bugs:%%References:% [1]: Bj鰎klund S.: "DBT, A MATLAB Toolbox for Radar Signal Processing.% Reference Guide", FOA-D--9x-00xxx-408--SE, To be published.%%See Also:% weightcols% * DBT, A Matlab Toolbox for Radar Signal Processing *% (c) FOA 1994-2000. See the file dbtright.m for copyright notice.%% Start : 981126 Svante Bj鰎klund (svabj).% Latest change: $Date: 2000/10/16 15:40:21 $ $Author: svabj $.% $Revision: 1.6 $% *****************************************************************************Y = ((diag(weights))*X);Y = full(sparse(diag(weights))*X);if (0)Y2 = full(spdiags(weights(:),0,size(X,1),size(X,1))*X);weightsMat = repmat(weights(:),[1,size(X,2)]);Y2 = X .* weightsMat;difference = sum(sum(abs(Y - Y2)));limit = 0.5*size(Y,1)*size(Y,2)*eps;if (difference > limit) difference error('Difference to large.')else %disp(' Test Ok.')end%ifend%if (0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -