MATLAB Answers

Is fullfile(0,0) undocumented behavior or bug?

1 view (last 30 days)
Naor Movshovitz
Naor Movshovitz on 18 Apr 2017
Commented: Walter Roberson on 19 Apr 2017
What is the purpose, if any, of non-char inputs to fullfile?
>> fullfile(0)
> In fullfile>refinePath (line 93)
In fullfile (line 38)
Warning: Inputs must be character arrays or cell arrays of strings.
ans =
0
>> fullfile(0,0)
ans =
\
>> fullfile(0,0,0)
ans =
\ \
>> fullfile(0,0,0,0)
ans =
\ \ \
etc. This is the behavior in R2014b and R2016b on Windows 7 (only versions I tested).

Accepted Answer

Jan
Jan on 18 Apr 2017
Edited: Jan on 18 Apr 2017
This is a bug. fullfile should contain a test, if all inputs are strings or character vectors. This happens for 1 input directly, but for multiple inputs, file sepearators are appended at first such that the elements are converted to character vectors implicitely.
I assume the warning is not correct also, but only a hard error is sufficient to stop the user driving fullfile beyond its purpose.
  3 Comments
Walter Roberson
Walter Roberson on 19 Apr 2017
More generally, isnumeric(fname) instead of comparing to 0.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!