Page 1 of 1

Problem with esfit from EasySpin 6.0.0 with generated functions

Posted: Mon May 13, 2024 9:18 am
by Emilien

Hello everyone,
I am working to make simlabel compatible with EasySpin 6.0.0...
I am facing a problem with esfit that was not present with previous eayspins.
Basically I try to use esfit with automatically generated functions and the problem is :

Code: Select all

Error using esfit
The simulation/model function given as second input cannot be found. Check the name.

You can find attached a code facing this problem. Note that the purpose of this code is just to illustrate this problem as simply as possible.
When running the code, be sure that 'temporary_func4esfit.m' is generated by the code and was not present in the current directory.

esfit_with_generated_function.zip
(6.27 KiB) Downloaded 217 times

Thanks for your help!

And congrats for this beautiful improvement of esfit!!!


Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Posted: Wed May 22, 2024 12:25 am
by Emilien

Have you made any progress?
Thanks again!


Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Posted: Wed Jun 05, 2024 4:01 pm
by Stefan Stoll

I am not able to reproduce this problem. It happens 1 out of 10 times, and I haven't been able to identify the problem.

esfit calls isa(fcn,'function_handle) first to make sure the supplied argument is a function handle, and then it calls nargin(fcn) to determine whether the function can be found. The latter appears to fail in your case. Maybe experiment with this. There could be some latency between your function generation and when MATLAB updates its internal list of callable functions.


Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Posted: Thu Jun 06, 2024 9:15 am
by Emilien

Thanks for these explanations!
I found that

Code: Select all

localfunctions;

updates this list! :D
i just add it before calling esfit and it works!


Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Posted: Fri Jun 07, 2024 5:12 pm
by Stefan Stoll

Excellent! Good find. rehash is possibly an alternative.