Running time Average of column values

2 visualizaciones (últimos 30 días)
Yash Bhati
Yash Bhati el 19 de Oct. de 2021
Editada: Yash Bhati el 19 de Oct. de 2021
I have to imported data form my simulation and made a table which is of Nx1 size.(N depends on number of output which i get from my simulation)
suppose my Table1 looks likes
1.10
2.20
3.20
4.40
......
now what i want is to create another Table2 which has running average of values from Table1, So my Table2 would look like
1.10
2.(10+20)/2
3.(10+20+20)/3
4.(10+20+20+40)/4
.....

Respuesta aceptada

KSSV
KSSV el 19 de Oct. de 2021
If A is your column array.
iwant = cumsum(A)./(1:numel(A))
  2 comentarios
dpb
dpb el 19 de Oct. de 2021
OP could also investigate
doc movmean
Yash Bhati
Yash Bhati el 19 de Oct. de 2021
Editada: Yash Bhati el 19 de Oct. de 2021
Thank you for your answers. Movmean works well. Code i wrote was this.
t=length(A);
M = movmean(A,[t 0]);
Although script as mentioned by KSSV (iwant = cumsum(A)./(1:numel(A))) works well but had to exract data from diagonal matrix.
Thank you all.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by