isfile
Determine if input is file
Description
result = isfile(
returns 1 if
fileName
)fileName
is a file located on the specified path or in the
current folder. Otherwise, isfile
returns 0.
Examples
Is Input a File
Check if the input myfile1.txt
is a file. A result of 1 indicates that myfile1.txt
is a file.
result = isfile('myfile1.txt')
result = logical
1
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')
result = logical
0
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
— File name
string array | character vector | cell array of character vector
File name, 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. If the file
is stored at a remote location, then fileName
must
contain a full path specified as a uniform resource locator (URL). For more
information, see Work with Remote Data.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Usage 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 code matches that of
stat/_stat
in the C language.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2017b
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)