tempname - Unique name for temporary file - MATLAB (original) (raw)

Main Content

Unique name for temporary file

Syntax

Description

tmpName = tempname returns a character vector containing a unique path for a temporary file in your system’s temporary folder.

example

tmpName = tempname([folderName](#mw%5F98d58600-dfdf-4cbe-9b0a-1c5a72c327e9)) returns a unique path for a temporary file in the specified folder.

example

Examples

collapse all

Create a temporary file name that has the extension, .dat, by concatenating two character vectors.

tmpName = [tempname,'.dat'];

Create a temporary file name for use in the C:\myTemporaryFiles folder.

tmpName = tempname('C:\myTemporaryFiles');

Create a temporary file name.

Create a new file with the temporary file name, and write data to the file.

fileID = fopen(filename,'w'); fwrite(fileID,magic(5)); fclose(fileID);

Input Arguments

collapse all

Folder name, specified as a string scalar or a character vector containing the folder name.

Version History

Introduced before R2006a