Problem with esfit from EasySpin 6.0.0 with generated functions

A place to report and discuss potential bugs
Post Reply
Emilien
Resident User
Posts: 69
Joined: Mon Apr 20, 2015 12:13 am

Problem with esfit from EasySpin 6.0.0 with generated functions

Post 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 972 times

Thanks for your help!

And congrats for this beautiful improvement of esfit!!!

Emilien
Resident User
Posts: 69
Joined: Mon Apr 20, 2015 12:13 am

Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Post by Emilien »

Have you made any progress?
Thanks again!

Stefan Stoll
EasySpin Creator
Posts: 1108
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Post 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.

Emilien
Resident User
Posts: 69
Joined: Mon Apr 20, 2015 12:13 am

Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Post 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!

Stefan Stoll
EasySpin Creator
Posts: 1108
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Problem with esfit from EasySpin 6.0.0 with generated functions

Post by Stefan Stoll »

Excellent! Good find. rehash is possibly an alternative.

Post Reply