generate random number with nonlinear constraints
2 次查看(过去 30 天)
显示 更早的评论
I want to generate 5 uniformly distributed random numbers whose upper and lower bounds will be upb=[4 2 -2.5 .9 -.1]; and lowb=[0 1 -4 -1 -.2]; respectively. These numbers should also satisfy 2 linear constraints and 2 nonlinear constraints. The linear constraints are: 1st lin const) sum of the 1st, 3rd, and 4th numbers have to be greater or equal to sum of the 2nd and 5th numbers. In other words sum(n1,n3,n4)>=sum(n2,n5). 2nd lin const) sum of the numbers should equal to 1. In other words sum(n1:n5)==1; And the nonlinear constraints are: 1st nonlin const) 0 <= (sin(n1) + cos(n2)) <= 0.2 2nd nonlin const) 7 < (n3^2 - n4) < 9
I know that, rand(1,5).*(upb-lowb)+lowb; will generate random numbers but I don't know how to use constraints.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!