Ok, I've managed to solve all my porblems. I still don't know how to use the suggested nested function, but instead I used handles to send extra parameters to the function, as in my above comment to Walter Roberson. In order to change variables in the base workspace I used the commands
evalin
assignin
So now I have full control over any variable through the ga's output function.
A nice thread I found, if anyone wants to review these commands: Use of evalin and assignin in ga output function