MATLAB: Question on the use of function ‘load’ to open a *.mat file

load

I have multiple *.mat files. So the filename is generated in a loop as below:
File = ['hb', num2str(A(i)), '.mat'];
When I tried to load it by doing:
load File;
I got the below error:
Error using load
Unable to read file 'File': no such file or directory.
Error in Combine_matfiles (line 17)
load File;
I am 100% sure the generated filename, File is correct, and the file is right there in the same directory. I can open it by typing load with the file name in the command window without any problem.
What did I do wrong? Thanks.

Best Answer

The statement:
load File
is equivalent to:
load('File')
What you want to do is
load(File)
This is a general MATLAB behavior for calling functions without using parentheses, not specific to just the load function. E.g., in general
myfunction thisinput thatinput
is equivalent to
myfunction('thisinput','thatinput')