Page 1 of 2

Curry esfit with Scaling None gives an error

Posted: Thu Oct 01, 2020 4:34 am
by niconeuman

Greetings,
I started trying to fit a set of magnetization curves with curry and esfit.
If I use Opt.Scaling = 'none', I get an error when starting the fitting in interactive mode:

Unrecognized function or variable 'scalefactor'.

Error in rescale

Error in esfit

Error in esfit_simplex

Error in esfit

Error while evaluating UIControl Callback.

But if I don't include that option it works fine, although then the fitting parameters would not make sense, because the g value dependence is on the maximum values of the magnetization. This also happens if I just change to No scaling in the interactive esfit window.
Is this a bug?
I have version 5.2.28
Best wishes,
Nicolas


Re: Curry esfit with Scaling None gives an error

Posted: Sun Oct 04, 2020 2:45 pm
by Stefan Stoll

Can you please post a minimal script that reproduces the problem, along with the experimental data you are trying to fit?


Re: Curry esfit with Scaling None gives an error

Posted: Mon Jan 11, 2021 7:07 am
by michs

Hi,

I noticed the same problem with version 5.2.29. However, it runs after reverting to 5.2.25. The curry_fit.m example file from the examples folder does not run the fitting because of this error message.

I also noticed that the onecoloumn option is gone in the development version 6.0. Has this been removed or is it available under a different name?


Re: Curry esfit with Scaling None gives an error

Posted: Thu Mar 04, 2021 9:14 am
by ecizmar

Maybe the problem is the existing "rescale" function in Matlab (Introduced in R2017b), we have two functions with the same name. Once FitOpt.Scaling is specified, the esfit fails because the original Matlab function "rescale" does not recognize this parameter. There is a need to rename the EasySpin rescale function and include this change into esfit.


Re: Curry esfit with Scaling None gives an error

Posted: Thu Mar 04, 2021 1:45 pm
by Stefan Stoll

This is an unfortunate consequence of the fact that all functions in MATLAB live in the same namespace.

The workaround is to make sure the EasySpin path comes first in your MATLAB path, so the other rescale function is shadowed and won't be called by esfit.


Re: Curry esfit with Scaling None gives an error

Posted: Fri Mar 05, 2021 3:08 am
by michs

Many thanks for your message. Do you mean to put easyspin first in the list of paths (Set Path window)? I tried that but this doesn't seem to solve the problem.


Re: Curry esfit with Scaling None gives an error

Posted: Fri Mar 05, 2021 3:18 pm
by Stefan Stoll

Yes, that's how it should work. Save the Path to make sure changes persist across sessions.

What do you get if you type which -all rescale in the Command Window? It should show something like

Code: Select all

C:\easyspin\easyspin\rescale.m
C:\Program Files\MATLAB\R2020b\toolbox\matlab\datafun\rescale.m        % Shadowed

This shows that MATLAB's rescale function is shadowed, and that EasySpins's rescale is called.


Re: Curry esfit with Scaling None gives an error

Posted: Mon Mar 08, 2021 2:53 am
by michs

I just ran

Code: Select all

which -all rescale

and I got the following:

Code: Select all

C:\EasySpin\easyspin-5.2.30\easyspin\rescale.p
C:\Program Files\MATLAB\R2020b\toolbox\matlab\bigdata\@tall\rescale.m            % tall method
C:\Program Files\MATLAB\R2020b\toolbox\parallel\parallel\@distributed\rescale.m  % distributed method
C:\EasySpin\easyspin-5.2.30\easyspin\rescale.m                               % Shadowed
C:\Program Files\MATLAB\R2020b\toolbox\matlab\datafun\rescale.m                  % Shadowed

I put easyspin in the first line in my list of paths, but Matlab nonetheless prefers those two tall and distributed methods over the easyspin rescale.m one. One workaround would be to remove these two toolboxes, but is there a different possible fix?


Re: Curry esfit with Scaling None gives an error

Posted: Mon Mar 08, 2021 5:35 am
by MPerfetti

Hello,
I get the same error and even removing the toolboxes does not seem to work.


Re: Curry esfit with Scaling None gives an error

Posted: Thu Apr 08, 2021 7:41 am
by christiansen

Hello

I have the same problem as michs. I get the exact same output with the command

$ which -all rescale

Also, putting EasySpin first in my path does not solve the problem. I'm running Matlab R2019b on Ubuntu 18.4 if that is important.