random matrix

I want to create 2 random matrixes (5x5). One where all the sums of the horizontal axis equal 1 and one where all the vertical axis equal to 1. Any help? Additionally all the random numbers should be ->x>1

답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 4월 13일

0 개 추천

x1 = rand(5);
x2 = rand(5);
x1 = bsxfun(@rdivide,x1,sum(x1,1));
x2 = bsxfun(@rdivide,x2,sum(x2,2));

댓글 수: 1

Oleg Komarov
Oleg Komarov 2011년 4월 13일
I would suggest http://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum since a normalization doesn't guarantee uniformly random sets.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2011년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by