Dear all , I still need an answer

1 view (last 30 days)
imola on 7 Aug 2014
Edited: imola on 17 Feb 2015
Dear Patrik thank you very much, that's really quick, but I see that the numbers have changed and the total number to every number is not 11, I'm going to be more precise, I need to have before the point four positions for example
[0011741667, 0003913892,0014488700,0008746350,0000349066] so the final string should be
while we got 1174173913914488787463034907 and I tried to change the { } to [] but it gave me error, in the end I have matrix [20,5] to convert in the same way , could you help me to overcome this problem. thanks
I will write my question again.
Dear all, I'm going to write my problem again, I need to convert the vector [11.741667 3.913892 14.488700 8.746350 0.349066] to integer numbers
[11741667 3913892 14488700 8746350 0349066] without the point, then join them to be string like 00117416670003913892001448870000087463500000349066
thanks in advance, I really appreciate your help.
Geoff Hayes
Geoff Hayes on 7 Aug 2014
Imola - the heuristic approach just takes the two equivalent genes/variables from the two parents and creates the child gene according to the equation
childVarX = parent2VarX + R * (parent1VarX - parent2VarX);
where parent1 has the better fitness value, and R determines how far the child variable value should be from the better parent. Just Google GA "heuristic crossover" and a couple of papers should appear.
Also see MATLAB GA Crossover Options and look at the heuristic section.

Sign in to comment.

Accepted Answer

Evan on 7 Aug 2014
Edited: Evan on 7 Aug 2014
Is this what you mean?
x = [0011741667,0003913892,0014488700,0008746350,0000349066];
s = regexprep(sprintf('%011.6f', x),'[.\s]','');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by