MATLAB: For an existing financial time-series object, is there a simple way to add columns

MATLABmatlab financial time series add new column pandas

I'm referring to pandas DataFrame as an example of adding a new ('return') column:
spy['return'] = spy['close'].pct_change()
What's the equivalent in matlab for the line above?
thx

Best Answer

digging a bit more, it seems fts behave a lot like structures ... so:
>> class(dt)
ans =
fints
>> dt.MA10 = fts2mat(tsmovavg(dt.Close, 's', 10))
dt =
desc: (none)
freq: Daily (1)
'dates: (2711)' 'Open: (2711)' 'High: (2711)' 'Low: (2711)' 'Close: (2711)' 'Vol: (2711)' 'OI: (2711)' 'MA10: (2711)'
'20-Mar-2006' [ 138.63] [ 139.44] [ 138.4] [ 139.31] [ 11992] [ 219881] [ NaN]
'21-Mar-2006' [ 140.59] [ 140.73] [ 139.85] [ 140.24] [ 15357] [ 214085] [ NaN]
will just add a new column ... or:
col_name = 'ma_20'
dt.(col_name) = fts2mat(tsmovavg(dt.Close, 's', 20))
dt =
desc: (none)
freq: Daily (1)
'dates: (2711)' 'Open: (2711)' 'High: (2711)' 'Low: (2711)' 'Close: (2711)' 'Vol: (2711)' 'OI: (2711)' 'MA10: (2711)' 'ma_20: (2711)'
'20-Mar-2006' [ 138.63] [ 139.44] [ 138.4] [ 139.31] [ 11992] [ 219881] [ NaN] [ NaN]
'21-Mar-2006' [ 140.59] [ 140.73] [ 139.85] [ 140.24] [ 15357] [ 214085] [ NaN] [ NaN]
'22-Mar-2006' [ 140.99] [ 141.33] [ 140.71] [ 140.87] [ 8884] [ 204050] [ NaN] [ NaN]
Simple after all...