MATLAB: How to copy a column I already have and add it on to the end of the matrix

columncopymatrix

I have some data with time followed by various parameters (see example below)
All I want to do is take the 3rd column (4th if you include the time) and create a new column at the end with the same data
2018-01-01T01:00 53.000 0.000 268.450 -1.000 0.100 157.000
2018-01-01T02:00 53.000 0.000 267.750 -1.000 0.200 51.000
2018-01-01T03:00 53.000 0.000 268.450 -1.000 0.100 142.000
2018-01-01T04:00 53.000 0.000 269.550 -1.000 0.200 14.000
I would really appreciate some help with this!
Thanks

Best Answer

EDITED
https://www.mathworks.com/help/matlab/ref/addvars.html - as you already have it as a table like shown in your previous question.
Example:
T=readtable('sample.txt'); % your rawdata filename
T.Var1=datetime(T.Var1,'Format','yyyy-MM-dd''T''mm:ss')
New=addvars(T,T{:,4},'After',size(T,2))
Gives:
New =
4×8 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8
________________ ____ ____ ______ ____ ____ ____ ______
2018-01-01T01:00 53 0 268.45 -1 0.1 157 268.45
2018-01-01T02:00 53 0 267.75 -1 0.2 51 267.75
2018-01-01T03:00 53 0 268.45 -1 0.1 142 268.45
2018-01-01T04:00 53 0 269.55 -1 0.2 14 269.55
Download the attached file to experiment.