Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

tempname

Unique name for temporary file

Syntax

Description

example

tmpName = tempname returns a string, tmpName, suitable for use as a temporary file path in your system's temporary folder.

Examples

expand all

Create Temporary File Name with Extension

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

tmpName = [tempname,'.dat'];

Write Data to Temporary File

Create a temporary file name.

filename = tempname;

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);

Limitations

  • In most cases, tempname generates a universally unique identifier (UUID). However, if you run MATLAB® without JVM™ software, then tempname generates a random string using the CPU counter and time, and this string is not guaranteed to be unique. For more information about the MATLAB startup option that does not load JVM software, see Commonly Used Startup Options.

See Also

Was this topic helpful?