This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Choose Appropriate Data Structures

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

When you create a new MuPAD® object, you choose the domain type of that object either explicitly or implicitly. Typically, MuPAD does not require you to declare domain types of simple objects, such as numbers, identifiers, or expressions. The system associates an object with a particular domain during run time.

When you create more complicated data structures, such as sets, lists, arrays, matrices, procedures, and so on, the syntax that you use to create these structures is a shortcut to the domain constructors. For example, matrix is a shortcut for the domain constructor Dom::Matrix with the default ring Dom::ExpressionField().

Also, when defining your own procedure, you can specify the types of arguments accepted by that procedure. In this case, for every call to that procedure, MuPAD automatically checks the types of provided arguments. For more information, see Checking Types of Arguments.

The domtype function returns the name of a domain to which an object belongs:

domtype([a, b, c])

When choosing a data structure for a new object, try to answer these questions:

  • Which features are essential to the new object? For example, some structures keep the initial order of elements, while other structures can change the order. Another example is that you can create multidimensional arrays, but you cannot create MuPAD matrices with more than two dimensions.

  • Which functions do you want to use on that object? Each MuPAD function accepts only objects of particular domain types. If an object that you pass to a function is not one of the acceptable domain types for that function, the function issues an error. To determine the domain types acceptable for a particular function, see the help page for that function. For example, you cannot use standard mathematical operations for MuPAD arrays.

If you already created an object, and then realized that it must belong to another domain type, try to convert the domain type of the object. See Converting Data Types.

Was this topic helpful?