How can I define a 1x3 array with "unifrnd" while second element must always be greater than first one?
조회 수: 2 (최근 30일)
이전 댓글 표시
mohamad hoseini
2017년 11월 5일
답변: Kaushik Lakshminarasimhan
2017년 11월 5일
I wanna use "unifrnd" command to produce a 1x3 array but conditionally I need the second element of the array to be always greater than the first element. Considering the example below: >> min=0; max=10; A=unifrnd(min,max,1,3)
A = 6.3 6.0 0.4
Now, How can I make it to select the second element always greater than first one.
Thanks,
댓글 수: 0
채택된 답변
Kaushik Lakshminarasimhan
2017년 11월 5일
minvals = min(A(:,1:2),[],2);
maxvals = max(A(:,1:2),[],2);
A(:,1) = minvals;
A(:,2) = maxvals;
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!