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 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by