lundi 4 janvier 2016

Creating Random Number row Vector within range ans sum should be equal to M

I am very confused with simple MATLAB random number generation problem. I know it looks silly and basic level some how but I have tried google before but could not find any useful solution.

I have bounds like this

  Lb = [150,100,150]; %in MW
  Ub = [600,400,200]; %in MW
  Pd = 850;   %in MW

I want to create a random guess which sum will be equal to Pd and which should be within limits of Lower and Upper Bounds.

I am able to generate row vector within limits like this

        `u0=Lb+(Ub-Lb).*rand(1,d);`

and I know that to generate random number which sum would be equal to Pd can be obtained like this

u0=rand(1,d);
u0=u0/sum(u0);
u0=u0*Pd;

How to combine both effect in single random number generation. thanks




Aucun commentaire:

Enregistrer un commentaire