sofacoustics / SOFAtoolbox

SOFA Toolbox (API for Matlab, Octave)
http://sofaconventions.org
European Union Public License 1.2
116 stars 31 forks source link

SOFAcheckFilename fails with strings (instead of char) #52

Closed HaHeho closed 2 years ago

HaHeho commented 2 years ago

SOFAcheckFilename('filename') works as expected. (although there is a problem with file names shorter than 7 characters due to the implmentation of checking for remote files ... this should be reworked as well.)

SOFAcheckFilename("filename") fails with "Filename must be a string.". This is due to strings and character vectors apparently being different things in Matlab. heavy eye rolling.

The function can be made work with strings in the following way. I didn't bother to make a PR (yet), since I don't know if you would want to make a proper rework of the function (i.e. not losing backwards compatibility towards Matlab versions before R2016b and being more error proof in general.

% filename = string?
if isstring(fn)
    fn = char(fn);
end
if ~ischar(fn)
    error('Filename must be a string.');
end
isfmiho commented 2 years ago

Thanks for reporting the issues. I fixed both of them, tested the functionality with Matlab and Ocatave, and commited the sources.