System.String 引数の受け渡し
System.String 引数を用いた .NET メソッドの呼び出し
.NET メソッドへの入力引数が System.String である場合、MATLAB® string スカラーまたは文字配列を渡すことができます。MATLAB は引数を System.String に自動的に変換します。たとえば、次のコードでは System.DateTime.Parse メソッドを使用して、char 配列で表される日付を DateTime オブジェクトに変換します。
strDate = "01 Jul 2010 3:33:02 GMT";
convertedDate = System.DateTime.Parse(strDate);
ToShortTimeString(convertedDate)
ToLongDateString(convertedDate)System.DateTime.Parse メソッドの関数シグネチャを表示するには、以下を入力します。
methodsview("System.DateTime")Parse のリストを検索します。
| 名前 | 戻り値の型 | 引数 | 修飾子 |
|---|---|---|---|
Parse | System.DateTime RetVal | (System.String s) | Static |
詳細については、以下を参照してください。
用語
System.DateTimeについては、Microsoft® Web サイトを検索してください。
MATLAB での System.String の使用法
この例では、System.String オブジェクトを MATLAB® 関数で使用する方法を説明します。
現在の時刻を表すオブジェクトを作成します。現在の時刻を示す thisTime は System.String オブジェクトです。
netDate = System.DateTime.Now; thisTime = ToShortTimeString(netDate); class(thisTime)
ans =
'System.String'
thisTime を MATLAB で表示するには、関数 string を使用して System.String オブジェクトを MATLAB string に変換します。
join(["The time is", string(thisTime)])
ans =
"The time is 13:21"