필터 지우기
필터 지우기

How to apply a weighting vector to a data matrix?

조회 수: 6 (최근 30일)
Yevgeniya
Yevgeniya 2012년 2월 3일
I want to apply a weighting vector wgt which is nx1 to a data matrix M which is nxm. In other words, I want to multiply each i-th (i=1:n) element of the weighting vector by a each element in i-th row of the matrix. If a vector is wgt=[1 2 3]' and a matrix is M=[1 2; 1 2; 1 2] the weighted matrix should be Mwgt=[1 2; 2 4; 3 6]. M is 3x2, wgt is 3x1. Thank you for your help.

채택된 답변

Sukuchha
Sukuchha 2012년 2월 3일
bsxfun(@times,M,wgt)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by