MATLAB: Percentage increase for table variables

rowfuntable

I have a 6×18 table. All with numeric values. How can I compute the percentage increase for all variables ? I tried using rowfun with diff(x) ./x(1:end-1)*100 but I am getting too many input variables error

Best Answer

If I'm understanding the problem correctly, the result would be an 6x17 matrix "M" where
% P is the 6x18 input table converted to a matrix
M(i,j) = (P(i,j+1)-P(i,j)) / P(i,j) * 100
If the table contains only numeric values which is how it's described in the question, it would be easier to convert it to a matrix.
T = array2table(randi(10,6,18)); % 6x18 numeric table
P = T{:,:}; % Convert to matrix
% Compute percent increase across rows (6x17 result)
M = diff(P,1,2)./P(:,1:end-1)*100