I have a (n,m) matrix T and a (n,1) vector a. I want to divide all the elements of n-th row with the n-th element of the column. Since I want to vectorize the process, I have tried the following
i = (1:n)';
out(i,:) = T(i,:)./a(i);
could it work or am I missing something? The indexing here do work when no component-wise operation is performed.

 채택된 답변

dpb
dpb 2015년 7월 1일

0 개 추천

>> T=ones(3);
>> a=1:3;a=a(:);
>> out=bsxfun(@rdivide,T,a)
out =
1.0000 1.0000 1.0000
0.5000 0.5000 0.5000
0.3333 0.3333 0.3333
>>

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2015년 7월 1일

댓글:

2015년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by