Element-wise multiplication for timetables

조회 수: 9 (최근 30일)
Nina
Nina 2019년 3월 26일
답변: Steven Lord 2019년 3월 27일
With elimination of fints, how can we do element-wise multiplication (.*) for two timetables?
Thank you!

답변 (1개)

Steven Lord
Steven Lord 2019년 3월 27일
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)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by