Iterate between fixed numbers in an array and store into a matrix.
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!