Borrar filtros
Borrar filtros

If I have a 2000 x 130 matrix, how do I convert it to a 500 x 130 matrix by adding all four rows together by using Matlab loop

2 visualizaciones (últimos 30 días)
.

Respuesta aceptada

KSSV
KSSV el 12 de En. de 2022
Editada: KSSV el 12 de En. de 2022
A = rand(2000,130) ;
[r,c] = size(A);
nlay = r/4;
B = permute(reshape(A',[c,r/nlay,nlay]),[2,1,3]);
iwant = reshape(sum(B),[],c) ;
  2 comentarios
Haytham Ali
Haytham Ali el 12 de En. de 2022
@KSSV thank you
Can you tell me how to sum all 4 elements or rows
Since I want to calculate the average for each of the four elements by calculating their sum divided by their number
KSSV
KSSV el 12 de En. de 2022
Sum is already included in the code.... To get the average just use mean. Read about this function.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by