MATLAB Answers

0

sum of row equal to particular number.

Asked by parag gupta on 20 Mar 2019
Latest activity Commented on by parag gupta on 20 Mar 2019
Accepted Answer by Jan
I have the following matrix
B = [2 2 2 3; ...
2 2 1 1; ...
4 5 2 1]
How to make sum of all these rows to be 0.0014. I mean sum of 1st row = 0.0014,sum of 2st row = 0.0014 and so on.Which matlab command I should use to transform the above matrix to a matrix with sum of 1st row = 0.0014,sum of 2st row = 0.0014 .
I tried to use randifix command but I dont want sum of coloums to be 0.0014.
Thanks

  2 Comments

I do not know a function called "randifix". So please mention, what you mean.
sorry ..its " randfixedsum "

Sign in to comment.

1 Answer

Answer by Jan
on 20 Mar 2019
Edited by Jan
on 20 Mar 2019
 Accepted Answer

B = [2 2 2 3; ...
2 2 1 1; ...
4 5 2 1]
Result = B ./ sum(B, 2) * 0.0014 % Auto-expand: >= R2016b

  1 Comment

thank you very much jan !
:)

Sign in to comment.