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

4 ビュー (過去 30 日間)
Ali Kareem
Ali Kareem 2015 年 11 月 2 日
コメント済み: Star Strider 2015 年 11 月 2 日
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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by