Divide rows of A by first entry of row
Show older comments
I am trying to divide each row of my matrix by its first row entry (to normalize the row).
I can do this for a single row (e.g. row 15 of 2D matrix 'sums'):
sums(15,1:end) ./ sums(15,1)
But this doesn't work:
sums(:,1:end) ./ sums(:,1);
Is there a way to do this in matrix notation, i.e., w/out looping?
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 9 Mar 2013
out=A./(repmat(A(1,:),size(A,1),[]))
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!