generating complex numbers with in a range in GA tool box

1 view (last 30 days)
i have a problem. i want to make random complex numbers like real part between (-0.5 to 0.5) and imaginary also -0.5i to 0.5i .
in the gatbx the range of the variable is found using rep function in matlab like
FieldD = [rep([PRECI],[1, NVAR]);
rep([-0.5-0.5;+0.5i+0.5i],[1, NVAR]);
rep([1; 0; 1 ;1], [1, NVAR])];
Chrom = crtbp(NIND, NVAR*PRECI);
Phen = bs2rv(Chrom,FieldD);
i wrote -0.5-0.5;+0.5i+0.5i. but this is not giving me what i want. in my phenotype this is giving me -(random)real-random(imag) and random(real)+random(imag). but it is skipping the numbers like -(random)real+random(imag) or random(real)-random(imag). e.t.c
can you help me with this one ..

Answers (1)

Geoff Hayes
Geoff Hayes on 3 Jan 2015
Hamza - are the functions rep, crtbp and bs2rv functions in the MATLAB Global Optimization Toolbox or in some other toolbox (that is not available from The MathWorks)? I couldn't find any documentation for these functions with the exception of rep in the Genetic and Evolutionary Algorithm Toolbox (GEATbx).
If you want to create a set of N complex numbers with real and imaginary parts in the interval (-0.5, +0.5), then why not try the following:
N = 50;
realPart = -0.5 + rand(N,1);
imagPart = -0.5 + rand(N,1);
cmplxData = complex(realPart,imagPart);
The above will create 50 complex numbers with real and imaginary parts that are within the interval (-0.5,+0.5).
  1 Comment
Hamza
Hamza on 4 Jan 2015
yes it is the gatbx in which crtbp and bs2rv are also present . yes i can use the procedure you mentioned , but it will get difficult for me to fit this with the chromosome and Phenotype generated. do you have any idea how can i fit this in the code i mentioned.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!