Q

Q Represents a transmission condition.

The Q class is used to define transmission conditions based on Boolean statements. A transmission condition is denoted as \(Q(b)\), where \(b\) is a Boolean statement involving variables x<num>, such as x1, x2, etc. Boolean statements should only contain AND (&) and NOT (!) operations.

Properties

  • vars (cell array of strings): Contains the Boolean variable expressions.
  • multiplier (vector of numbers): Multipliers associated with each term.

Methods

  • Q: Constructor to create a transmission condition.
  • and: Overloads & (logical AND) for Q objects.
  • or: Overloads | (logical OR) for Q objects.
  • not: Overloads ~ (logical NOT) for Q objects.
  • disp: Custom display function.
  • display: Calls disp for better formatting.

Usage

% Define variables as transmission conditions
x = arrayfun(@(i) Q(sprintf('x%d', i)), 1:10);
q = (x(1) | x(2)) & ~x(3);

% Alternatively, define variables separately
x1 = Q('x1');
x2 = Q('x2');
x3 = Q('x3');
q = (x1 | x2) & ~x3;

% Creating Q objects with multipliers
q = Q('x1 & !x3', 1);
q = Q({'x1', 'x2', 'x1 & x2'}, [1, 1, -1]);

Notes

  • The recommended constructor is Q(i), where i is an integer representing a variable index.
  • Other constructors are for internal use and may lead to incorrect results if misused.
  • DO NOT use OR (|) inside the string input for Q, as it is not supported.

Q Construct a transmission condition.

obj = Q(vars) constructs a transmission condition with the given variable. obj = Q(vars, multiplier) constructs a transmission condition with a specified multiplier.

Arguments

  • vars (string, cell array of strings, or integer): The variable(s) in the Boolean condition. Must be formatted as x<num>.
  • multiplier (number or vector): Multiplier(s) associated with each term.

Returns

  • obj (Q): A transmission condition.

Example

q = Q('x1');            % Single variable
q = Q({'x1', 'x2'}, [1, -1]);  % Multiple variables with multipliers

Notes

  • The recommended way to define a variable is using Q(i), where i is an integer representing a variable index.
  • Users should not directly specify OR (|) inside the variable strings.

| Combine two transmission conditions using a logical OR.

result = q1 | q2 performs a logical OR operation between two transmission conditions, returning a new Q object.

Arguments

  • obj1 (Q): First transmission condition.
  • obj2 (Q): Second transmission condition.

Returns

  • result (Q): The combined transmission condition.

Example

q1 = Q(1);
q2 = Q(2);
q = q1 | q2;

See also and (&), not (~)

~ Negate a boolean condition using the logican NOT.

result = ~q negates a transmission condition, creating a condition where the given Boolean statement does not hold.

Arguments

  • obj (Q): A transmission condition to negate.

Returns

  • result (Q): The negated transmission condition.

Example

q1 = Q(1);
q = ~q1;

Notes

  • If the condition consists of a single variable, it is simply negated.
  • If the condition is more complex, an auxiliary "T" (true) condition is used and the returned condition is equivalent to \(Q(T) - Q(b)\) where \(b\) is the origional Boolean condition.

See also and (&), or (|)

& combine two transmission conditions using logical AND.

result = q1 & q2 performs a logical AND operation between two transmission conditions, returning a new Q object. This is the same as \(Q(b \land b')\) where \(b\) and \(b'\) are the Boolean conditions for q1 and q2 respectively.

Arguments

  • obj1 (Q): First transmission condition.
  • obj2(Q): Second transmission condition.

Returns

  • result(Q): The combined transmission condition.

Example:

q1 = Q(1);
q2 = Q(2);
q = q1 & q2;  % Returns Q("x2 & x1")

See also or (|), not (~)

disp Display a transmission condition in either systems form or dynamic form.

disp(q) displays the transmission condition using the systems form notation.

disp(q, order) displays the transmission condition using the dynamic form notation, where order is the variable ordering defined by the transmission matrix.

Arguments

  • q (Q): A transmission condition.
  • order (vector of integers, optional): The variable ordering defined by the transmission matrix. If provided, the condition is displayed using the dynamic form notation.

Example

q = makeCondition("x1 | x2");

disp(q); % Displays condition in systems form.

order = [3, 1, 2];
disp(q, order); % Displays condition in dynamic form.