필터 지우기
필터 지우기

How can i randomly move the values of a vector

조회 수: 1 (최근 30일)
zahid
zahid 2015년 7월 23일
답변: Thorsten 2015년 7월 23일
Hi everyone.
Suppose i have a column vector X=[1;2;5;7;8].Now i want randomly arrangement of the values of this vector.For example X1=[2,7,8,1,5] is one of such random arrangement.My purpose is to randomly movement of this vector values and then add it to another vector say Y in one of my simulation experiment.
THANKS WITH BEST WISHES

채택된 답변

Manolis Michailidis
Manolis Michailidis 2015년 7월 23일
  댓글 수: 1
Manolis Michailidis
Manolis Michailidis 2015년 7월 23일
sorry now i took a better look here try this
X=[1;2;5;7;8];
n=length(X);
y = datasample(X,n,'Replace',false)

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

추가 답변 (1개)

Thorsten
Thorsten 2015년 7월 23일
X = X(randperm(numel(X));

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by