MATLAB: Is it possible to append if file doesnt already exist

save

is it possible that matlab creates the file if it doesnt exist in append mode? i run a program which produces gb's of data. so i keep saving the variables in a file in steps and clear the variables.so i use append. but it says "Unable to write file samp.mat: No such file or directory." i use save function.

Best Answer

The save command needs an existing file for appending. This can be caught easily:
if exist(FileName, 'file')
save(FileName, '-append');
else
save(FileName);
end
It could be much faster to write a binary file using FPRINTF.