This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Pass System.String Arguments

Call .NET Methods with System.String Arguments

If an input argument to a .NET method is System.String, you can pass a MATLAB® string scalar or character array. MATLAB automatically converts the argument into System.String. For example, the following code uses the System.DateTime.Parse method to convert a date represented by a char array into a DateTime object:

strDate = "01 Jul 2010 3:33:02 GMT";
convertedDate = System.DateTime.Parse(strDate);

To view the function signature for the System.DateTime.Parse method, type:


Search the list for Parse.

QualifiersReturn TypeNameArguments
StaticSystem.DateTime RetValParse(System.String s)

For more information, see:

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"

Related Topics