MATLAB: Error using save Unable to write file datafiles/f01.mat: No such file or directory.

MATLABno such file or directorysave

keep getting this error for simple save function. heres my code
if (jrandflag == 1) o = jrand.createShiftVector(D, lb, ub); o = o'; save('datafiles/f01.mat', 'o'); else load('datafiles/f01.mat'); o = o(1:D); end
datafiles folder does exist in same directory; expect'd save function to create f01.mat but error every time. and code not in loop per se
Can anyone help please? Thanks
Matlab version 7.10.0.499 (R2010a) on windows platform

Best Answer

'datafiles/f01.mat' isn't the full path of the file, is it? If you mean to save it in the current folder, try.
save(fullfile(pwd,'datafiles/f01.mat'));