Contenu principal

pystringarray

Convert MATLAB string array to Python NumPy string array

Since R2026a

    Description

    npa = pystringarray(mla) converts the specified MATLAB® string array to a NumPy StringDType array. This function requires NumPy 2.0 or a later release.

    example

    Examples

    collapse all

    Convert the MATLAB string array mla to a NumPy StringDType array npa.

    mla = ["sandwich" "salad" missing; "samosa" "soup" "sushi"]
    mla = 2×3 string array
        "sandwich"    "salad"    "<missing>"
        "samosa"      "soup"     "sushi"
    
    
    npa = pystringarray(mla)
    npa = 
      Python ndarray:
    
        [['sandwich' 'salad' None]
         ['samosa' 'soup' 'sushi']]
    
        Use details function to view the properties of the Python object.
    
        Use string function to convert to a MATLAB array.
    
    

    Input Arguments

    collapse all

    Input array, specified as a string array of any size.

    Output Arguments

    collapse all

    Output array, returned as a NumPy StringDType array. The dimensions of npa are the same as the dimensions of mla.

    Version History

    Introduced in R2026a