Element-wise multiplication for timetables
9 views (last 30 days)
Show older comments
With elimination of fints, how can we do element-wise multiplication (.*) for two timetables?
Thank you!
0 Comments
Answers (1)
Steven Lord
on 27 Mar 2019
A timetable can contain many different types of data, some of which define element-wise multiplication and some of which don't. The easiest way to perform arithmetic on a specific numeric variable in a timetable is to index into the timetable.
thedates = datetime('today')+days(0:5);
TT = array2timetable(magic(6), 'RowTimes', thedates)
y = TT.Var3 .* TT.Var5
If you want to perform the same operation on all numeric variables in your timetable you can do that using vartype.
y2 = TT{:, vartype('double')}.^2
TT{:, vartype('double')} = y2
If the data stored in the timetable can be concatenated into a numeric array, you could reference all of it at once.
TT.Variables = sqrt(TT.Variables)
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!