Gistlib Logo

gistlib

substract two columns of a table in matlab

Suppose you have a table T with columns Column1 and Column2. The following code will create a new column named Column3 with the difference of Column1 and Column2.

main.m
T.Column3 = T.Column1 - T.Column2;
35 chars
2 lines

You can also subtract a scalar value from a column like this:

main.m
T.Column3 = T.Column1 - 10;
28 chars
2 lines

Note that this will subtract 10 from each element of Column1 and create a new column Column3 with the result.

similar matlab code snippets

how to make a timetable with one column in matlab
how to convert from table to time in matlab
write a script which will print a table on screen of the temperature in celsius and the corresponding temperature in fahrenheit from 0o c to 100o c in steps of 5o c in matlab
take rows in an array and put them in a table in matlab
convert cell array to table in matlab
write a script which will print a table on screen of the temperature in celsius and the corresponding temperature in fahrenheit from 0 to 100 in steps of 5 in matlab
index the last 5 rows of a table in matlab
index the first 7 rows of a table in matlab
update gui from table in matlab
write a while loop that multiplies uservalue by 2 while all of the following conditions are true: uservalue is not 10 uservalue is less than 25 in matlab

related categories

matlab
table
arithmetic-operation

gistlibby LogSnag