I was wondering if it's possible to run hidden .m
files in MATLAB. Take the following MWE:
My working directory contains two files: main.m
and .foo.m
which is hidden (in Linux, hidden files are preceded by a .
)
dir
|
+-- main.m
+-- .foo.m (hidden)
The file .foo.m
contains:
disp('bar');
And main.m
contains a call to .foo.m
via the run
command
run('.foo.m');
When I run main.m
, MATLAB throws an error:
>> main
Error using run (line 61)
.foo.m not found.
Error in main (line 1)
run('.foo.m');
However if I run ls -a
and dir
, they both display the hidden file inside the directory:
>> ls -a
. .. .foo.m main.m
>> dir
. .. .foo.m main.m
So it seems that MATLAB cannot find hidden files by default (at least in Linux).
Is there a way to enable running hidden scripts or functions in MATLAB?
EDIT:
Just realized that putting a .
at the beginning of the file violates MATLAB's file naming rules:
Source: Specify File Names
"File names must start with a letter, and can contain letters, digits, or underscores."