Data2Dynamics / d2d

a modeling environment tailored to parameter estimation in dynamical systems
https://github.com/Data2Dynamics/d2d
57 stars 29 forks source link

Bug in arMyStr2Sym connected to MATLAB version #165

Open laasfeld opened 3 years ago

laasfeld commented 3 years ago

When calling arMyStr2Sym the function call fails. The problem seems to be on line 17

if(str2double(matver.Version) >= 9.4)

It branches into the else caluse and causes further problems with symbolic conversions for Matlab version 2021a as matver.Version value is '9.10' and str2double(matver.Version) equals 9.1, which of course is smaller than 9.4. Possible solution is using verLessThan function (for example "if(~verLessThan('matlab', '9.4'))" ) or something similar. verLessThan is added in R2007a so there should be sufficient backwards compatibility.

laasfeld commented 3 years ago

Similar problem in arCcode line 113.

adrianhauber commented 3 years ago

Thanks for pointing this out, should be fixed now!

adrianhauber commented 3 years ago

It seems this issue extends further than I originally thought. Multiple functions, including arCompileAll, arPlotMulti, arLink, arPlotX, arPlotY, arPlotV, arSym, arSubs, arSubsRepeated, arPlot2, arLoadData, arLoadModel, arReport, arMiniReport, check the Matlab version using ver('matlab') and convert to result to double.

I implemented an ad hoc solution by replacing all occurrences of ver('matlab') with arVer, which has the same output as ver('matlab') but changing the Version field to 9.91 for 9.10.

As this issue will persist for all future 9.x versions, it will become increasingly difficult to keep track of version specific behaviour. I propose to use verLessThan as suggested by @laasfeld instead, which is also the recommended way of implementing version specific behaviour by MathWorks.