필터 지우기
필터 지우기

How to find the average of a single column in matrix

조회 수: 33 (최근 30일)
Alex Doan
Alex Doan 2020년 2월 5일
답변: Divya Gaddipati 2020년 2월 10일
i have a 17x6 matrix and i want to find the average of the last column WITHOUT hardcoding meaning if that matrix becomes a 16x4 it will still calculate the avg

답변 (1개)

Divya Gaddipati
Divya Gaddipati 2020년 2월 10일
Hi,
If m is your matrix, to get the last column and mean, you can use:
last_col = m(:, end)
avg = mean(last_col);
Hope this helps!

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by