Demo entry 6770503

Rando

   

Submitted by Sam on Nov 13, 2018 at 16:47
Language: Matlab. Code size: 435 Bytes.

function x = rand_samp(n,ub,lb,N)

for i = 1:N
    for j = 1:n
        x(j,i) = lb(j) + (ub(j) - lb(j))*rand(1);
    end
end


function x = star_rand(n,N,ub,lb)

m = N.^(1/n);
bin = (ub-lb)./m;

temp = bin*rand(n,N);

for i = 1:m
    for j = 1:m
        x(1,(i-1)*m+j) = lb(1) + bin(1)*(j-1);
    end
end

for i = 1:m
    for j = 1:m
        x(2,i+(j-1)*m) = lb(2) + bin(2)*(j-1);
    end
end

x = x + temp;

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).