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!