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. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page. class


Parameter in query portion of uniform resource identifier (URI)


Use the QueryParameter class to create a URI query string of the form:


where each name=value segment is a QueryParameter object, converted to a string using the string method. The string method on a vector of QueryParameter objects joins the results using the & character. The string method converts any values to strings and performs all necessary encoding of special characters in the result.


obj = creates an empty query parameter.

obj =,paramValue) creates a query parameter vector of paramName,paramValue pair arguments. You can specify several argument pairs in any order as paramName1,paramValue1,...,paramNameN,paramValueN.


obj = creates a query parameter vector from a structure.


obj = parses qStr into the query.

obj =,Format) specifies the format to be used for nonscalar values, and can include any of the input arguments in previous syntaxes.

Input Arguments

expand all

Parameter name, specified as a string or character vector.

Parameter value, specified as a type required by paramName.

Parameter names and values, specified as a structure. The fields of qStruct define the parameter names and values.

Data Types: struct

Parameter names and values, specified as a string or character vector. The qStr is a completed, encoded query as it would appear in a URI, with an optional leading ? character.

qStr is split at the & characters into individual name=value query parameters. The Name property is set to name and the Value property is set to value.

A triplet of characters of the form % and two hex digits represents a percent-encoded byte. A sequence of these bytes is treated as UTF-8 encoded characters. For example, the UTF-8 encoding for the euro sign () is E2 82 AC.

q1 ='V=%e2%82%ac')
q1 = 

  QueryParameter with properties:

      Name: "V"
     Value: "€"
    Format: csv

The + and %20 characters are treated as spaces.

q2 ='V=a+b%20c')
q2 = 

  QueryParameter with properties:

      Name: "V"
     Value: "a b c"
    Format: csv

The string method implements percent-encoding on characters that require encoding. For example, the is encoded.

ans = V=%E2%82%AC

However, the characters in the qStr argument 'V=a+b%20c' do not need encoding.

q3 = string(q2)
q3 = V=a+b+c

Although the result from the string method does not match qStr, the values are identical when used in a URI.


expand all

Parameter name, specified as a string or character vector.

Parameter value, specified as a real number, logical, datetime (with value other than NaT), string, character vector, or a vector or cell vector of these values. If Value is any other type, then Value must support string or char methods that convert the value to a character vector. If empty, Value is treated as an empty string.

Encoding format, specified as a enumeration, to use for encoding Value if it is a vector.


charEncoded query parameter as character vector
stringEncoded query parameter as string




expand all

Create a structure field name this and set it to the value that.

qStruct.this = 'that';
QP =
QP = 
  QueryParameter with properties:

      Name: "this"
     Value: 'that'
    Format: csv

Create a character vector with two queries, this=that and one=2. The QueryParameter method splits qStr at the & character into two QueryParameter objects.

qStr = '?this=that&one=2';
QPs =;

The name=value pairs in qStr define the Name and Value properties.

name1 = QPs(1).Name
name1 = 
value1 = QPs(1).Value
value1 = 
name2 = QPs(2).Name
name2 = 
value2 = QPs(2).Value
value2 = 

Introduced in R2016b

Was this topic helpful?