adding each element of a matrix by previous elements of that row.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mohsen ebneali
el 9 de Sept. de 2021
Comentada: Star Strider
el 9 de Sept. de 2021
Hey guys,
I have a matrix and I want to make a new matrix in such a way in each row, each element is the summ of the prevous elements + current element divided by the number of elements. for example if
a = [1 2 3;4 5 6;7 8 9]
is the first matrix, the second matrix should be;
b = [1 3/2 6/3; 4 9/2 15/3; 7 15/2 24/3]
0 comentarios
Respuesta aceptada
Star Strider
el 9 de Sept. de 2021
Try this —
a = [1 2 3;4 5 6;7 8 9]
acs = cumsum(a,2)
b = acs ./ (1:size(a,2))
ratsb = rats(b)
Experiment to get different results.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays 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!