Main Content

isfile

Determine if input is file

Description

result = isfile(文件名)returns 1 if文件名是一个文件定位d on the specified path or in the current folder. Otherwise,isfilereturns 0.

Examples

collapse all

Check if the inputmyfile1.txtis a file. A result of 1 indicates thatmyfile1.txtis a file.

result = isfile('myfile1.txt')
result =logical1

Create the foldermyfolder, then check ifmyfolderis a file. A result of 0 indicates thatmyfolderis not a file.

mkdirmyfolder; result = isfile('myfolder')
result =logical0

Check if the inputsmyfile1.txtandmyfolderare files. A result of[1 0]indicates thatmyfile1.txtis a file andmyfolderis not a file.

result = isfile(["myfile1.txt","myfolder"])
result =1×2 logical array1 0

Input Arguments

collapse all

File name, specified as a string array, character vector, or cell array of character vectors. For a local file,文件名can include a relative path, but the relative path must be in the current folder. Otherwise,文件名must include a full path. If the file is stored at a remote location, then文件名must contain a full path specified as a uniform resource locator (URL). For more information, seeWork with Remote Data.

Extended Capabilities

Version History

Introduced in R2017b