StollLab / EasySpin

MATLAB toolbox for Electron Paramagnetic Resonance (EPR) spectroscopy
http://easyspin.org
MIT License
48 stars 26 forks source link

rescale.m #209

Closed ecizmar closed 3 years ago

ecizmar commented 3 years ago

rescale.m called by esfit.m does have the same name as Matlab function "rescale" introduced in Matlab R2017b, in result, esfit fails when FitOpt.Scaling is defined

stestoll commented 3 years ago

This is an unfortunate consequence of MATLAB's design where all functions share the same namespace.

One workaround is to make sure that the EasySpin folder easyspin-x.y.z/easyspin is on the MATLAB path before the path to the other function (toolbox/matlab/datafun I believe). In this case, MATLAB's rescale will be shadowed, and esfit will call EasySpin's rescale.

For EasySpin version 6, we can consider renaming the function to avoid this clash.

stestoll commented 3 years ago

When pressing F1 on rescale in the editor, the documentation page for MATLAB's rescale function appears, even though it is shadowed:

>> which -all rescale
C:\easyspin\easyspin\rescale.m
C:\Program Files\MATLAB\R2021a\toolbox\matlab\bigdata\@tall\rescale.m  % tall method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datafun\rescale.m        % Shadowed

Tested on R2021a.

It looks like we might need to rename the EasySpin function.

stestoll commented 3 years ago

I filed a service request with MathWorks regarding this. Response is that they won't fix this behavior. So EasySpin has to rename the function.