usefulcodes.blogspot.com
AboutME
ajabgajabBLOG
nabinkm.com
NewPost
Tuesday, August 18, 2009
Get the desired number of samples
I was wondering how to get n number of sample outputs constrained by the situations given.
AB > C^2
accept C
else reject C
however, I need n non zero final samples.
Wrote this one:
It works for me!
function Obj = get_random_v3(Obj, n)
% n=250
j=1;
v = zeros(1,n);
notOK3 =1;
while notOK3
Obj(j).v1 = rand();
Obj(j).v2 = rand();
Obj(j).v3 = rand();
if (Obj(j).v1*Obj(j).v2) > ((Obj(j).v3)^2)
v(j) = Obj(j).v3;
j=j+1;
end
v(v == 0) = [];
if (length(v) == n) %&& (length(v6) == n) && (length(v9) == n) && (length(v12) == n)
notOK3=~notOK3;
end
end
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)