Subtracting column values in Matlab tables
Show older comments
Hi All, I have a table in matlab with 84 rows and 3 columns. I want to subtract values in column 3 from column 2. How do I do that. Thanks,
Accepted Answer
More Answers (2)
the cyclist
on 10 Mar 2018
Edited: the cyclist
on 10 Mar 2018
The exact syntax will depend a little on how your table was created. Here are a couple examples.
N = 84;
v1 = rand(N,1);
v2 = rand(N,1);
v3 = rand(N,1);
T = table(v1,v2,v3);
diffT = T.v2 - T.v3;
or
T = table(rand(84,3));
T.Var1(:,2) - T.Var1(:,3)
1 Comment
Eric Akomeah
on 10 Mar 2018
the cyclist
on 10 Mar 2018
If you are using the word "table" loosely -- meaning you actually just have a numeric array and not a table data type, then you can just do
T = rand(84,3);
diffT = T(:,2) - T(:,3);
Categories
Find more on Time Series Events 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!