How to find multiple means of an array
1 回表示 (過去 30 日間)
古いコメントを表示
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.
採用された回答
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!