How to convert Matlab code to Delphi? -


how convert part of matlab code delphi?

for i=1:popsize      fi=rand(1,dimension); % generate vector of uniform random numbers     p=pbest(i,:);     pbest(i,:)=x(i,:); end 

my code:

for i:= 1 popsize begin   fi:= // function generates vector of uniform random numbers in delphi?   k :=1 popsize   begin     p:=pbest(i,k);     pbest(i,k):=x(i,k);   end; end; 

you can call random function generate uniformly distributed random value. calling randomize once makes random generate different values in each run.

var   fi: array of double;   j: integer; begin   randomize;   j := 0 dimension - 1     fi[j] := random; end; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -