필터 지우기
필터 지우기

Error using ==> rdivide

조회 수: 4 (최근 30일)
Matlab2010
Matlab2010 2012년 6월 11일
For
w = randn(10, 51300);
w = w./ sum(w,1);
i get
??? Error using ==> rdivide
Matrix dimensions must agree.
For each column of 10 elements, I wish to divide each element by sum(w,1).
How can I do this without using a for loop? thanks

채택된 답변

the cyclist
the cyclist 2012년 6월 11일
Use the bsxfun() function:
>> w = bsxfun(@rdivide,w,sum(w,1));

추가 답변 (1개)

Greg Heath
Greg Heath 2012년 6월 13일
clear all, clc
rng(4151941)
w = randn(2, 3)
w1 = w./ repmat(sum(w),2,1)
w2 = bsxfun(@rdivide,w,sum(w))
e12 = norm(w1-w2)
Hope this helps.
Greg

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by