[FID, MSG] = tmpfile(); % Return the file ID corresponding to a new temporary filename = tmpnam (...); % generates temporary file name, but does not open file [FID, NAME, MSG] = mkstemp (TEMPLATE, DELETE); % Return the file ID corresponding to a new temporary file with a unique name created from TEMPLATE.