How to calculate the average value of selected row, column from a given matrix.

조회 수: 5 (최근 30일)
U B
U B 2023년 2월 14일
답변: U B 2023년 2월 14일
I have a matrix A =[ 16 2 3 13 16 ; 5 11 10 8 8 ; 9 7 6 12 5; 4 14 15 1 3] . I want to calculate the avarage value for A(i.j) where i ranges from 1 to 3 and j from 0 to 2. Can You please help me with this?

채택된 답변

U B
U B 2023년 2월 14일
A = magic(5);
n = A(2:4,1:3); % value I want to read
M = mean2(n);

추가 답변 (1개)

Arif Hoq
Arif Hoq 2023년 2월 14일
편집: Arif Hoq 2023년 2월 14일
A =[ 16 2 3 13 16 ; 5 11 10 8 8 ; 9 7 6 12 5; 4 14 15 1 3]
A = 4×5
16 2 3 13 16 5 11 10 8 8 9 7 6 12 5 4 14 15 1 3
i=1:3;
j=1:2;
out_each_col=mean(A(i,j),1)
out_each_col = 1×2
10.0000 6.6667
out_each_row=mean(A(i,j),2)
out_each_row = 3×1
9 8 8

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by