I try to load a .mat file in MATLAB R2016a. However, when I make the filename variable, it fails with
Error using load Unable to read file 'filename'. No such file or directory.
The documentation for R2018a states that the filename has to be
specified as a character vector or string
which i did. I searched for similar questions on SO, but they were all due to typing errors, e.g. Error using load; Unable to read file matlab
Code for reproduction:
clear all
mat1 = magic(5);
save mat1
clear mat1
load mat1 % working
clear mat1
filename = 'mat1.mat'; % tried with/without .mat
load filename % not working
- What is the cause of this error?
- How to resolve it?