Hi
I try to use the function, but I have a problem when I'm driving.
I have a matrix A (193.1) I would like to create a matrix (193.3) whose sum equals one line to my matrix A.
I tried the following code but I meet an error:
Rhedgefund = Y (:, 1);
cols_to_generate = 3;
for K = 1: length (Y)
Neva (K, :) = randfixedsum (1 cols_to_generate, Y (K), -0.15, 0.15);
end
He told me:
Index EXCEEDS matrix dimensions.
Error in randfixedsum (line 95)
x = (b-a) * x (p + repmat ([0: n: n * (m-1)] n, 1)) + a; % Switches & rescale x
95 x = (b-a) * x (p + repmat ([0: n: n * (m-1)] n, 1)) + a; % Switches & rescale x
I do not know how to solve problem

Comment only

10 Apr 2013

Random Vectors with Fixed Sum
Randomly and uniformly generates vectors with a specified sum and values in a specified interval.

i am trying to generate 6 random nmbrs within given range and sum:
xmin=[10 10 40 35 130 125];
xmax=[125 150 250 210 325 315];
Pg=randfixedsum(1,6,200,xmin, xmax);
it is giving following error:
?? Error using ==> minus
Matrix dimensions must agree.
Error in ==> randfixedsum at 56
s1 = s - (k:-1:k-n+1); % s1 & s2 will never be negative
Error in ==> busdatas at 47
Qg=randfixedsum(30,1,total(8),xmin, xmax);
can sm1 tell wats wrong..i cnt figure it out..

Comment only

08 Jun 2012

Random Vectors with Fixed Sum
Randomly and uniformly generates vectors with a specified sum and values in a specified interval.

Comment only