How to average certain columns in a matrix
조회 수: 8(최근 30일)
표시 이전 댓글
I have a 107x16 matrix, the first column is time data, the last 15 are data points. I'd like to average the 15 data columns and collapse this matrix into a 107x2 matrix of time and average data.
Thank you!
댓글 수: 0
채택된 답변
madhan ravi
2021년 7월 2일
편집: madhan ravi
2021년 7월 2일
matrix = rand(107, 16);
Matrix = [matrix(:, 1), mean(matrix(:, 2 : end), 2)];
size(Matrix)
댓글 수: 0
추가 답변(1개)
madhan ravi
2021년 7월 2일
T = array2table(rand(2, 3))
T = [T(:, 1), array2table(mean(T{:, 2 : end}, 2), 'V', {'AVERAGE'})] % where Var1 is the time data
댓글 수: 0
참고 항목
범주
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!