主要内容

isfilePathInclusive

Determine if input is file in current folder, specified location, or MATLAB path

Since R2026a

    Description

    tf = isfilePathInclusive(filename) returns logical 1 (true) if filename is a file located in the current folder, at the specified location, or on the MATLAB® path. Otherwise, isfilePathInclusive returns logical 0 (false).

    example

    Examples

    collapse all

    Check if myfile1.txt is a file on the MATLAB path. A result of 1 indicates that myfile1.txt is a file on the MATLAB path. The file is either in the current folder or in a folder on the path.

    tf = isfilePathInclusive("myfile1.txt")
    tf = logical
       1
    
    

    Check if myfolder is a file on the MATLAB path. A result of 0 indicates that myfolder is not a file on the MATLAB path.

    tf = isfilePathInclusive("myfolder")
    tf = logical
       0
    
    

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

    tf = isfilePathInclusive(["myfile1.txt", "myfolder"])
    tf = 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. The filename input can also contain a partial path for files on the MATLAB 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.

    Output Arguments

    collapse all

    True or false result, returned as 1 or 0 of data type logical.

    Limitations

    • MATLAB does not support internet URLs that require authentication.

    • For remote locations that require authentication, isfilePathInclusive interprets only the first location (which might be the authentication page) and ignores further redirects.

    • 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

    expand all

    Version History

    Introduced in R2026a