メインコンテンツ

nozc

Remove zero crossings

Since R2026a

Parent Section: equations

Syntax

nozc(expression)
nozc(expression,ignoreZC)

Description

The nozc operator removes zero crossings from Simscape™ Language expressions. Use this operator on continuous and smooth expressions to remove zero crossings added by functions, relational operators, and operators, such as mod, >, or and. If you use the operator on a discontinuous expression, or an expression where the derivative changes abruptly, the simulation may have issues with accuracy or convergence. For a list of functions that can generate zero crossings, see equations.

To toggle the removal of zero crossings, you can optionally include a second operand. nozc(expression,ignoreZC) removes zero crossings from the expression when the Boolean ignoreZC is true, which is the default behavior. When ignoreZC is false, the operator does nothing and does not remove the zero crossings.

Assumptions and Limitations

  • Using nozc in event predicates does not remove zero crossings. For example, this expression creates a zero crossing when x becomes greater than or equal to 1.

    events
      when edge(nozc(x >= 1))
        d = d + 1;
      end
    end

    For more information about event predicates, see Discrete Event Modeling.

  • When you use nozc on a function that converts data types, the expression may include zero crossings. For example, this expression creates a zero crossing every time the converted integer changes value.

    x1 == nozc(int32(x2));

Examples

expand all

This expression includes the mod function and the <= relational operator. The <= relational operator introduces a zero crossing when I becomes greater than the value of threshold. The mod function introduces a zero crossing each time I is evenly divisible by the value of wrap. The nozc operator removes these zero crossings.

O == nozc(if I <= threshold, I else mod(I, wrap) end);

Version History

Introduced in R2026a