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);
class(thisTime)
ans =

  1×13 char array

System.String

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

disp(['The time is ' char(thisTime)])
The time is 14:53