필터 지우기
필터 지우기

Selecting specific rows and then summing them up

조회 수: 2 (최근 30일)
okoth ochola
okoth ochola 2022년 7월 15일
댓글: Chunru 2022년 7월 16일
Hi, suppose I have a matrix A=[1 2 3 4 5 6 7 8 9 10 11 13......12555], I want to select specific elements and add them up in one value. Selection is done after uniform interval. For example, I let the first value to be selected in 1 in the first row and then the next value I would select should be in the tenth row which is the value 10, the next value would be in the 20th row and so on. Then sum all these values together and find their mean. Kindly help me figure out how to go about it. Thanks.

채택된 답변

Chunru
Chunru 2022년 7월 15일
A=[1:12555];
B = A(10:10:end); % choose 10,20,30,...
mean(B)
ans = 6280
  댓글 수: 3
Stephen23
Stephen23 2022년 7월 15일
A=[1:12555];
% ^ ^ totally superfluous, get rid of them.
Chunru
Chunru 2022년 7월 16일
@Stephen23 See the question https://www.mathworks.com/matlabcentral/answers/1761460-or-in-constructing-array

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by