Back with the answer.
My solution was to implement this code with nested functions. In function A I have defined a variable 'history'. I have changed the call to function B (which includes a second call to fminsearch) with a call to a nested function A2. In A2 I'm calling B and B feeds 'history ' (common to A and A2) with the information provided by the second fminsearch.
I'm open for a better approach.
minibela