Subtracting mean from table column and creating new Column with solution
Show older comments
Hey guys,
I'm new to matlab and stuck:
I have 30x10 table and I'm trying to do the following:
I'm attempting to take the values from column 5 and subract them from the mean of column 10.
I've already calculated the mean but I'm struggling to figure out how i can calculate the value of each individual row and subract it from the mean and add it a new column row in one function.
Would that be possible?
Thanks guys
Answers (2)
Walter Roberson
on 28 Nov 2020
t.NewColumn = mean(t{:,10}) - t{:,5};
1 Comment
Tarun bhalla
on 28 Nov 2020
M.Many
on 28 Nov 2020
%M = rand(30,10);
%T = array2table(M)
T{:,11}= mean(T{:,10})-T{:,5} % Replace T by your Table
3 Comments
Walter Roberson
on 28 Nov 2020
Note: the column that is introduced will be named 'Var11' unless there is an existing 'Var11', in which case it will be named 'Var11_' followed by a digit.
M.Many
on 28 Nov 2020
True, thanks for the additional note.
Tarun bhalla
on 28 Nov 2020
Categories
Find more on Introduction to Installation and Licensing 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!