MATLAB Examples

Use System.String in MATLAB

This example shows how to use a System.String object in a MATLAB® function.

Create an object representing the current time. The current time thisTime is a System.String object.

netDate = System.DateTime.Now;
thisTime = ToShortTimeString(netDate);
ans =


To display thisTime in MATLAB, use the string function to convert the System.String object to a MATLAB string.

join(["The time is", string(thisTime)])
ans = 

    "The time is 13:21"