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

1 visualización (últimos 30 días)
Saji Kamdod
Saji Kamdod el 28 de Oct. de 2019
Editada: Stephan el 28 de Oct. de 2019
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.

Respuestas (1)

Stephan
Stephan el 28 de Oct. de 2019
Editada: Stephan el 28 de Oct. de 2019
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);

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by