Element-wise multiplication for timetables

9 vues (au cours des 30 derniers jours)
Nina
Nina le 26 Mar 2019
With elimination of fints, how can we do element-wise multiplication (.*) for two timetables?
Thank you!

Réponses (1)

Steven Lord
Steven Lord le 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)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by