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

 채택된 답변

Adam Danz
Adam Danz 2020년 8월 28일
편집: Adam Danz 2020년 8월 28일

0 개 추천

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

Adam Danz
Adam Danz 2020년 8월 28일
Taole Tsoehlisi's answer moved here as a comment
Works perfectly thanks
Adam Danz
Adam Danz 2020년 8월 28일
편집: Adam Danz 2020년 8월 29일
Glad I could help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2020년 8월 28일

편집:

2020년 8월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by