フィルターのクリア

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 Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by