Fix bug in chisquare_inv.m related to vers variable parsing in MATLAB versions >= 10 #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the wave_matlab/chisquare_inv.m script, the vers variable (used to determine the MATLAB version) has a bug: it strips only the first character of the version string to retain as a compatibility check. This results in an incorrect encoding where the vers variable only captures the most significant version digit for MATLAB versions 10 and above.
For example, the current MATLAB version R2024b (version 24) would be parsed as 2. Consequently, in the subsequent if statement, the depreciated fmin function is selected and the script crashes. For MATLAB versions < 100, 10-59 would be affected.
Solution:
Option 1 (preserving backward compatibility): Using functionalities that would be available in legacy MATLAB versions, could update as vers = str2double(datestr(version('-date'), 'yyyy')) to check the release year. This would ensure compatibility with older versions, preserving the intended functionality for fmin.
Option 2 (final solution): However, since fmin has been depreciated for a long time, I opted to remove vers and all its dependencies. The code would now always use fminbnd.