Create an object protected against evaluation
MuPAD® notebooks will be removed in a future release. 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.
block(a) creates a block — an object
of special type that contains an unevaluated copy of
It is treated as atomic and remains unchanged by evaluation.
block and domains derived thereof form a
hierarchy of data types designed to provide control over the evaluation
of certain subexpressions. Any object can be put as content into any
type of block.
block is a domain If
any block domain,
d(a) creates a block belonging
to that domain, with content
block(a) puts its argument into a block,
without evaluating it. In order to evaluate
before putting it into a block, use
Blocks are invariant under evaluation.
Blocks of type
block are atomic: the only
operand of a block is the block itself.
You can create further block domains using inheritance. This
particularly useful for creating own
See Example 4.
A block is a sort of container that protects its content against evaluation:
y := 1: bl:= block(1 + y)
Blocks are atomic; thus
not visible as operands:
Although blocks are not arithmetical expressions, some basic arithmetical operations are defined for them:
collect(x + bl + x*bl, bl)
delete y, bl
A block can also contain a sequence; flattening is suppressed:
The content of a block can be extracted and evaluated using
y := 1: unblock(block(y))
Create blocks that represent arithmetical expressions. To do
this, you need your own block domain that overloads
domain myblock inherits block; category Cat::BaseCategory; testtype:= (bl, T) -> if T = Type::Arithmetical or T = dom then TRUE else block::testtype(bl, T) end_if; end_domain:
This lets you to make the number zero invisible for the evaluator by enclosing it into a block, but to retain the option to plug it into special functions:
f := sin(x+myblock(0))
Now you can manipulate this expression, without being disturbed by automatic simplification:
Any object or sequence of objects
block creates objects of its own type.