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