필터 지우기
필터 지우기

How to find multiple means of an array

조회 수: 2 (최근 30일)
Darrien Walters
Darrien Walters 2020년 10월 22일
댓글: Darrien Walters 2020년 10월 22일
I have an array and I'm trying to make another array consisting of mean values of the first array.
I have some code i used to try and solve it myself using a for loop
A= (1:10);
b = 2;
c=1;
for i = 1:10
d(:,i) = mean(A(b:c));
b=b+1;
c=c+1;
end
Any suggestions or changes would be much appreciarted as this code currently doesn't work.
  댓글 수: 1
Darrien Walters
Darrien Walters 2020년 10월 22일
For anyone wondering i figured out my issue. this code is fine for what i needed it to do

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

채택된 답변

Image Analyst
Image Analyst 2020년 10월 22일
Yes, A(b:c) is A(2 : 1) which is null since your starting index, 2, is after your ending index, 1. So that's why it didn't work.
  댓글 수: 1
Darrien Walters
Darrien Walters 2020년 10월 22일
Yes thanks alot not sure how that slipped past me

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by