MATLAB: How to create a loop that runs through the rows of a table

for looplooptable

I am trying to create a loop that runs through a table (2016 x 2) that takes the data from each column and inputs it into an equation and plots each result for each row. This is what I have attempted so far however, I am struggling to get this to work. Any help would be greatly appreciated.
rows = height(T);
for row = 1:rows
a1=T(row,1);
a2=T(row,2);
P=a1*a2;
end
hold on
plot(p,row)

Best Answer

You don't need a for loop for this.
P=T{:,1}.*T{:,2};
plot(P)