Reputation: 2907
I'm trying to load a mat file in Matlab by:
file = 'DSC (1)';
load file;
but I get this error:
Unable to read file 'file'. No such file or directory.
On the other hand by:
load 'DSC (1)';
It works.
Any idea, why the first one does not work?
Upvotes: 1
Views: 231
Reputation: 21561
You are using the Matlab script syntax, rather than the (recommended) function syntax.
load(file)
would execute load on the contents of variable file
. As the variable file contains a string with the right location, this will work.
However load file
or load 'file'
will execute load on the string 'file'
. As there is no file called 'file' this will not work.
Upvotes: 4