generating random values from another matrix with a random value in rows only

Hi I have this code
X = rand(113,401); % sample matrix
% generate random indices and use them to pull values from A
B = X(round(rand(11300,401)*(numel(X)-1))+1);
but i want only exchange randomly in the row so value in row 1 in X can go randomly in any rows in B matrix only not in any column of B matrix

 채택된 답변

James Tursa
James Tursa 2017년 9월 12일
편집: James Tursa 2017년 9월 12일
Is something like this what you want? Randomly distributed values from X but staying in same column?
X = whatever
rows = desired number of rows of the result B
[M,N] = size(X);
B = X(bsxfun(@plus,randi(M,rows,N),M*(0:N-1)));

추가 답변 (0개)

카테고리

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

질문:

2017년 9월 12일

편집:

2017년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by