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) forQobjects.or: Overloads|(logical OR) forQobjects.not: Overloads~(logical NOT) forQobjects.disp: Custom display function.display: Callsdispfor 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), whereiis 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 forQ, 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 asx<num>.multiplier(number or vector): Multiplier(s) associated with each term.
Returns
obj(Q): A transmission condition.
Example
Notes
- The recommended way to define a variable is using
Q(i), whereiis 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
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
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:
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.