MATLAB: The error using “load” and “fgets” codes in MATLAB 2013a

load fgets

I just want to use "load" command and "fgets" command in same time.
fid is a txt file which contains the directories of 40 seperate file.
fid=
materialproperties/uniaxialelement1.txt
materialproperties/uniaxialelement2.txt
materialproperties/uniaxialelement3.txt
….
….
….
So i use fgets(fid) to get the directory of any file as
fgets(fid)= materialproperties/uniaxialelement2.txt
then I need the data of this file so i use" load" command
Read_Pr=load(fgets(fid))
this code work efficently in MATLAB 2014a but i have to run the code in MATLAB 2013a but i get an error.
So what can i do for running this code without any errors in MATLAB2013a?
Whats is difference in using "load" code?

Best Answer

Use fgetl, not fgets:
Read_Pr = load(fgetl(fid))
% ^
As its help clearly states, fgets includes the newlines at the end of the line (so this will not be a valid filename) but fgetl removes the newlines (giving a valid filename).