Find mean and mean square root of each row in matrix without first row and column

조회 수: 4 (최근 30일)
Hi,
How I can find mean and mean square root of 10*10 matrix for each row in matrix and save them in matrix C(:,1) without including first row and column. for example if matrix A is 4*4
1 3 3 4
2 5 7 6
8 4 9 4
2 1 6 9
how I can find mean and mean square root of each row in matrix without including first row (1 3 3 4)and first column (1 2 8 2) in calculation?
I do not want to delete them from matrix because I need them later in my calculations.
Regards

답변 (1개)

Star Strider
Star Strider 2015년 11월 2일
I am guessing that you want the root mean square of the rows, as well as the arithmetic mean, omitting the first row and the first column.
This will do that:
A = [1 3 3 4
2 5 7 6
8 4 9 4
2 1 6 9];
A_row_mean = mean(A(2:end, 2:end), 2)
A_row_rms = sqrt(mean(A(2:end, 2:end).^2, 2))
  댓글 수: 2
Ali Kareem
Ali Kareem 2015년 11월 2일
Hi,
Thank you for your reply. but some times in my matrix it is another row or column or more than one
How I can do that?
Regards
Star Strider
Star Strider 2015년 11월 2일
Using your current matrix, if instead you wanted to eliminate columns 2 and 3 and row 3, the code changes to:
A_row_mean = mean(A([1:2 4], [1 4]), 2) % Without Row 3, And Without Columns 2 & 3
A_row_rms = sqrt(mean(A([1:2 4], [1 4]).^2, 2))
You have to specify the rows and columns you want to keep in the calculaton. Those you do not specify are not used.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by