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
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
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
- MATLAB® does not support internet URLs that require authentication.
- MATLAB Online™ supports internet URLs associated with Microsoft® OneDrive™ files and folders, while the installed version of MATLAB supports only local OneDrive files.
Extended Capabilities
Usage notes and limitations:
- Use of
file:
in the specified path is not supported. - No preprocessing is applied on the specified path.
- In certain cases, the behavior of the generated code might differ from MATLAB. In such cases, the behavior of the generated
C
code matches that ofstat
on UNIX® andGetFileAttributesA
on Windows®.
Version History
Introduced in R2017b
You can read data from primary online sources by performing file read operations over an internet URL.