Borrar filtros
Borrar filtros

Average numbers in array

1 visualización (últimos 30 días)
Krasimir Terziev
Krasimir Terziev el 4 de Ag. de 2021
Comentada: Krasimir Terziev el 4 de Ag. de 2021
Hello,
I've got an array with 65926x2 values. I try to make average when the 1st column got numer of 600 and write in the a new array as 1st cell. Then i want a next average till the numer of 1st column is 1200. What i mean is the time_space_average=[0:600:604800];
So at the end i want to have an array with 1009x1 elements. i will put excel table and picture of the data arrays!
Thanks in advance!

Respuestas (1)

KSSV
KSSV el 4 de Ag. de 2021
You may proceed some like this shown below:
T = readtable('C:\Users\KSSV\Downloads\1.xlsx') ;
x = T.(1) ; y = T.(2) ;
idx = 0:600:604800;
[c,ia] = ismember(idx,x) ;
n = length(ia);
iwant = zeros(n-1,2) ;
for i = 1:n-1
iwant(i,:) = [idx(i) mean(y(i:i+1))] ;
end
  1 comentario
Krasimir Terziev
Krasimir Terziev el 4 de Ag. de 2021
Hello,
Thanks for the fast answer!
I've got a different answers from that code.
What i mean is 1st.
i change this -> x = T.(1) ; y = T.(2) ; to this -> x = T(:,1); y = T(:,2);
so after that change, the code worked, but
the answer of "iwant" is from 0 to 604200 (not to 604800) - > it can be from 600 ( because average of one number at the zero is the same number) till 604800 including.
and the last one:
When i make average of the numbers in excel table -> there is not equal between the iwant 2nd column = 600 - 233.637405484499 and the table 600 - 233.790024856455.
i will put the same table with 2 average calculations, so the logic have to be the same.
If i miss somethink, just tell me :) im newbie at coding
i will wait for ur respon.
Thanks again!

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by