# how to range data and find maximum value for each range by using loop

5 visualizaciones (últimos 30 días)
abdullah al-dulaimi el 29 de Jun. de 2022
Comentada: abdullah al-dulaimi el 29 de Jun. de 2022
I have data (AB) consisting of two columns. The number of rows of this data is 80315. I want to divide this number into (1: 2000: 80315) and take the maximum values for each period (based on the second column, also i want to index the firt colum).
I using this code but its very long.
a = AB([1:2000],:);
aa=max(a);
a1 = AB([2000:4000],:);
aa1=max(a1);
a11 = AB([4000:6000],:);
aa11=max(a11);
maxvalues=([aa;aa1;aa11])
##### 2 comentariosMostrar NingunoOcultar Ninguno
Pooja Kumari el 29 de Jun. de 2022
According to your code, you want to get maximum value for each period, what do you mean by second column?
abdullah al-dulaimi el 29 de Jun. de 2022
i mean the output will be 2 coluoms not 1

Iniciar sesión para comentar.

Pooja Kumari el 29 de Jun. de 2022
Editada: Pooja Kumari el 29 de Jun. de 2022
It is my understanding that you are facing issues with huge vector and instead of hardcoding, you want a generalized form of code for taking the maximum value for your data for each period by taking 2000 data at a time out of 80315 rows of data.
Please find below an example code for the same with random dataset of 80315 rows and 2 columns:
data = rand(80315,2); %data
index = 1;
for i = 1:1999:80315-1999
array_data = data(i:i+1999,:); %data is divided into %2000 samples at a time.
output(index,1) = max(array_data(:)); %taking max of all values in a period
index = index +1;
end
Sincerely,
Pooja Kumari
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
abdullah al-dulaimi el 29 de Jun. de 2022
dear Pooja Kumari ,
Thank you for your kind efforts.
best regard

Iniciar sesión para comentar.

### Categorías

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

R11.1

### Community Treasure Hunt

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

Start Hunting!

Translated by