Main Content

isdlarray

Check if object is dlarray

Since R2020b

    Description

    tf = isdlarray(X) returns logical 1 (true) if X is a dlarray, and logical 0 (false) otherwise. You can use this function with an if statement to avoid executing code that expects dlarray input.

    example

    Examples

    collapse all

    Create a 2-by-3-by-4 array of random values.

    X = rand(2,3,4)
    X = 
    X(:,:,1) =
    
        0.8147    0.1270    0.6324
        0.9058    0.9134    0.0975
    
    
    X(:,:,2) =
    
        0.2785    0.9575    0.1576
        0.5469    0.9649    0.9706
    
    
    X(:,:,3) =
    
        0.9572    0.8003    0.4218
        0.4854    0.1419    0.9157
    
    
    X(:,:,4) =
    
        0.7922    0.6557    0.8491
        0.9595    0.0357    0.9340
    
    

    Check if the array is a dlarray object.

    isdlarray(X)
    ans = logical
       0
    
    

    Convert the array to dlarray.

    X = dlarray(X)
    X = 
      2x3x4 dlarray
    
    
    (:,:,1) =
    
        0.8147    0.1270    0.6324
        0.9058    0.9134    0.0975
    
    
    (:,:,2) =
    
        0.2785    0.9575    0.1576
        0.5469    0.9649    0.9706
    
    
    (:,:,3) =
    
        0.9572    0.8003    0.4218
        0.4854    0.1419    0.9157
    
    
    (:,:,4) =
    
        0.7922    0.6557    0.8491
        0.9595    0.0357    0.9340
    
    

    Check if the array is a dlarray object.

    isdlarray(X)
    ans = logical
       1
    
    

    Input Arguments

    collapse all

    Input variable, specified as a workspace variable. X can be any data type.

    Extended Capabilities

    Version History

    Introduced in R2020b