Direct computation with Table

Description

You can perform calculations directly on tableswithout needing to index into them.

To perform such operations using the same syntax as you would for arrays, your tables must meet several criteria:

All variables within the table must have data types that support the intended calculations (e.g., numeric or logical types).

When performing an operation where only one operand is a table, the other operand must be either a numeric or logical array.

For operations involving two tables, they must have compatible sizes (i.e., the same number of rows and columns or the operation must make sense for the structures involved).

Below is an example that demonstrates how to perform calculations without explicitly indexing into the table.

Example

Direct computation on Tables

% Create a sample table with sensor data
T = table([1.5; -2.3; 4.7], [0.5; 1.1; -0.7], [-1; 2; 3], ...
          'VariableNames', {'Voltage', 'Current', 'Resistance'});

% Apply functions directly to the table columns
abs(T)
acos(T)
acosh(T)
T > 1
T + 2
T .* T
abs(sin(T)) + 1

See also

abs, acos, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, asecd, asech, asin, asind, asinh, atan, atand, atanh, ceil, cosd, cosh, cospi, cot, cotd, coth, csc, cscd, csch, exp, fix, floor, log, log10, log1p, log2, nextpow2, round, sec, secd, sech, sin, sind, sinh, sinpi, sqrt, tan, tand, tanh, var, acosd, not, plus, minus, times, eq, ge, gt, le, ne, lt, mrdivide, rem, power, pow2, or, mod, ldivide.

History

Version
Description

1.9.0

initial version

Author

Allan CORNET

Last updated