Curry esfit with Scaling None gives an error

A place to report and discuss potential bugs
niconeuman
User
Posts: 11
Joined: Mon Oct 22, 2018 1:16 am

Curry esfit with Scaling None gives an error

Post 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

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

Re: Curry esfit with Scaling None gives an error

Post by Stefan Stoll »

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

michs
Newbie
Posts: 5
Joined: Fri May 10, 2019 3:21 am

Re: Curry esfit with Scaling None gives an error

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

ecizmar
Newbie
Posts: 4
Joined: Mon Jan 12, 2015 4:40 am

Re: Curry esfit with Scaling None gives an error

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

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

Re: Curry esfit with Scaling None gives an error

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

michs
Newbie
Posts: 5
Joined: Fri May 10, 2019 3:21 am

Re: Curry esfit with Scaling None gives an error

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

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

Re: Curry esfit with Scaling None gives an error

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

michs
Newbie
Posts: 5
Joined: Fri May 10, 2019 3:21 am

Re: Curry esfit with Scaling None gives an error

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

MPerfetti
Newbie
Posts: 6
Joined: Sat Jun 30, 2018 2:10 am

Re: Curry esfit with Scaling None gives an error

Post by MPerfetti »

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

christiansen
User
Posts: 21
Joined: Thu Apr 08, 2021 7:38 am

Re: Curry esfit with Scaling None gives an error

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

Post Reply