Percentage increase for table variables

I have a 6x18 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

 采纳的回答

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

2 个评论

Taole Tsoehlisi's answer moved here as a comment
Works perfectly thanks
Glad I could help!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by