Error using ==> rdivide
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
the cyclist
am 11 Jun. 2012
Use the bsxfun() function:
>> w = bsxfun(@rdivide,w,sum(w,1));
0 Kommentare
Weitere Antworten (1)
Greg Heath
am 13 Jun. 2012
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Detection finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!