isfile - Determine if input is file - MATLAB (original) (raw)

Main Content

Determine if input is file

Syntax

Description

result = isfile([filename](#d126e923392)) returns 1 iffilename is a file located on the specified path or in the current folder. Otherwise, isfile returns 0.

Examples

collapse all

Check if the input myfile1.txt is a file. A result of 1 indicates that myfile1.txt is a file.

result = isfile('myfile1.txt')

Create the folder myfolder, then check if myfolder is a file. A result of 0 indicates that myfolder is not a file.

mkdir myfolder; result = isfile('myfolder')

Check if the inputs myfile1.txt and myfolder are files. A result of [1 0] indicates that myfile1.txt is a file and myfolder is not a file.

result = isfile(["myfile1.txt", "myfolder"])

result = 1×2 logical array 1 0

Input Arguments

collapse all

Filename, specified as a string array, character vector, or cell array of character vectors. For a local file, filename can include a relative path, but the relative path must be in the current folder. Otherwise, filename must include a full path.

For files and folders at a remote location, you must specify the full path as a uniform resource locator (URL). Internet URLs must include the protocol type "http://" or "https://". For more information, see Work with Remote Data.

Limitations

Extended Capabilities

expand all

Usage notes and limitations:

Version History

Introduced in R2017b

expand all

You can read data from primary online sources by performing file read operations over an internet URL.