Documentation

Define String Scalar Inputs

You can define string scalar inputs at the command line or in theMATLAB®Coder™app. Programmatic specification of string scalar input types by using preconditioning (assertstatements) is not supported.

Define String Scalar Types at the Command Line

To define string scalar inputs at the command line, use one of these procedures:

Alternatively, if you have a test file that calls your entry-point function with example inputs, you can determine the input types by usingcoder.getArgTypes.

Provide an Example String Scalar Input

To provide an example string scalar tocodegen, use the-argsoption:

codegenmyFunction-args{"Hello, world"}

Provide a String Scalar Type

To provide a type for a string scalar tocodegen:

  1. Define a string scalar. For example:

    s ="mystring";

  2. Create a type froms.

    t = coder.typeof(s);

  3. Pass the type tocodegenby using the-argsoption.

    codegenmyFunction-args{t}

Provide a Constant String Scalar Input

To specify that a string scalar input is constant, usecoder.Constantwith the-argsoption:

codegenmyFunction-args{coder.Constant("Hello, world")}

Provide a Variable-Size String Scalar Input

To specify that a string scalar input has a variable-size:

  1. Define a string scalar. For example:

    s ="mystring";

  2. Create a type froms.

    t = coder.typeof(s);

  3. Assign theValueproperty of the type to a type for a variable-size character vector that has the upper bound that you want. For example, specify that typetis variable-size with an upper bound of 10.

    t.Properties.Value = coder.typeof('a',[1 10], [0 1]);

    To specify thattis variable-size with no upper bound:

    t.Properties.Value = coder.typeof('a',[1 inf]);

  4. Pass the type tocodegenby using the-argsoption.

    codegenmyFunction-args{t}

Define String Scalar Inputs in theMATLABCoder应用程序

To define string scalar inputs in the app, use one of these procedures:

See Also

||

Related Topics