Good day,
I want to fit some parameters (around 50) for a model implemented in a DLL and am using lsqcurvefit. Unfortunately I have noticed Matlab halts sometimes within that optimisation and the only way to resume it is killing Matlab and restart Matlab. Matlab tells me then to have encountered an internal problem. Sometimes it happens on first parameter set, sometimes on 40th. The author of the DLL told me, the model is not very stable and it can happen, that the answer is not an array of double but an array which contains INF entries. I do not know, but I guess this makes Matlab hold.
First idea was to write down every parameter set and get to know the bounds for parameters. But this is not good approach because combination of some parameters may cause this behaviour. Excluding both parameters from parameter space would exclude some parameter combinations which can actually work. Creating such rules of possible combinations would need way too much effort.
Now I am searching, how to wrap a time condition around the calllib command. If time is over and there is no understandable result, the result could be set to zero or excluded. I tried to make a function_handle for that calllib command and use it with wait(fun,'finished',1). But "wait" does not work with function_handles. How can I put the command into a job to use it with wait? Or is there a way to remove the DLL job if failed and prevent Matlab from halting? I do not know, whether such approach could work with a DLL but basically I am thinking of something simple like:
try('time',1) [answer1, answer2 , answer3] = calllib(DLL,'function',length,array1, array2 ,array3);catch [answer1, answer2 , answer3] = [zeros(1,length), zeros(1,length) , zeros(1,length)];end
Thanks for you help!
Tom
Best Answer