Iterate between fixed numbers in an array and store into a matrix.

조회 수: 6 (최근 30일)
Saji Kamdod
Saji Kamdod 2019년 10월 28일
편집: Stephan 2019년 10월 28일
I'm trying to iterate an array for the first 250 element and store certain values like the max, min, mean and peak2peak in a array. I first want to iterate the 250 elements out of an array of 98000 and store these values in a different array and then continue from 251st element until it reaches 98000.

답변 (1개)

Stephan
Stephan 2019년 10월 28일
편집: Stephan 2019년 10월 28일
I suggest to reshape the array to have 250 rows. The most Matlab functions like mean, max, min, sum... work on the columns of an array by default, so this is easy to write. For example:
A = randi(100,10,5)
A_mean = mean(A)
A_max = max(A)
A_min = min(A)
A =
37 51 88 23 44
63 52 56 18 12
79 82 63 23 26
9 80 59 44 41
93 65 21 32 60
78 38 31 93 27
49 82 48 44 61
44 54 24 19 72
45 36 85 91 23
31 94 20 98 12
A_mean =
52.8000 63.4000 49.5000 48.5000 37.8000
A_max =
93 94 88 98 72
A_min =
9 36 20 18 12
To reshape use:
A = reshape(YourArrayName,250,[]);
Writing them all in one array would work this way:
A_properties(1,:) = mean(A);
A_properties(2,:) = max(A);
A_properties(3,:) = min(A);

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by