Random Number generation with Total sum.
显示 更早的评论
clear all ; clc Demand=300; N=10; D=3;
a(1:N,1)=100; b(1:N,1)=600; %bounds on variable 1
a(1:N,2)=100; b(1:N,2)=400; %bounds on variable 2
a(1:N,3)=50; b(1:N,3)=200; %bounds on variable 3
x=a+(b-a).*rand(N,D);
I want to generate random numbers whose sum is equal to Demand=300 and their bounds are specified. When I generate by this code their sum is not equal to Demand, Please tell me what to do ?
Note-> I have studied randfixedsum function in Matlab help but it doesn't help me.
2 个评论
Sean de Wolski
2014-12-23
Please don't start new questions for the same thing as an existing one.
Instead, answer my question that I posed to you:
WHY DOESN'T RANDFIXEDSUM HELP YOU?
John D'Errico
2014-12-28
编辑:John D'Errico
2014-12-28
Sean - randfixedsum assumes the points lie in a hyper-cube, not a hyper-rectangle. The question here has lower and upper limits that differ for each variable. The randfixedsum code assumes scalar a and b.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!

