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).

The matrix operators *, / and \ perform element-wise multiplication and division (like .*, ./ and .\) when one operand is a table or timetable and the other operand is a scalar. Any other combination is an error: use the element-wise operators instead.

The unary operators - and + apply to every variable of a table or timetable.

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

💡Examples
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
T * 2
10 / T
-T
abs(sin(T)) + 1
🔗See Also
absacosacoshacotacotdacothacscacscdacschasecasecdasechasinasindasinhatanatandatanhceilcosdcoshcospicotcotdcothcsccscdcschexpfixfloorloglog10log1plog2nextpow2roundsecsecdsechsinsindsinhsinpisqrttantandtanhvaracosdnotplusminustimeseqgegtleneltmrdividerempowerpow2ormodldividemtimesmldivideuminus
🕔Version History
Version Description
1.9.0 initial version
2.0.0 mtimes (*), mrdivide (/) and mldivide (\) perform element-wise operations between a table or timetable and a scalar.
Edit this page on GitHub