How can I store values from loops in a vector?
이전 댓글 표시
If I have a column of 50 rows and I want to store in a new vector the sum of first to third row, then second to fourth, etc.. how could be the code? thanks in advance
답변 (3개)
turquoise_squid
2017년 1월 5일
1 개 추천
reshape the vector with the command 'reshape' to a n x m matrix and perform the mean on its rows.
Steven Lord
2017년 1월 5일
1 개 추천
댓글 수: 3
Philippe Corner
2017년 1월 5일
Philippe Corner
2017년 1월 5일
Image Analyst
2017년 1월 5일
It's only in R2016a or later.
Image Analyst
2017년 1월 5일
Try conv():
data = rand (50, 1); Sample data.
kernel = [1;1;1]/3; % Kernel to computer the mean of 3.
movingMeans = conv(data, kernel, 'valid') % Mean of 1-3, 2-4, 3-5, etc.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!