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

4 views (last 30 days)
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

Answers (1)

Star Strider
Star Strider on 2 Nov 2015
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 Comments
Ali Kareem
Ali Kareem on 2 Nov 2015
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 on 2 Nov 2015
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.

Sign in to comment.

Categories

Find more on Shifting and Sorting Matrices 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!