Borrar filtros
Borrar filtros

Matrix Manipulation from 4D to 3D

2 visualizaciones (últimos 30 días)
Amine Ben Ayara
Amine Ben Ayara el 12 de Dic. de 2016
Comentada: Amine Ben Ayara el 12 de Dic. de 2016
Good morning Matlab Community, I hope all of you are doing well. I need some help with manipulating matrix dimensions. I have 4D matrix of the following dimension (5*5 by14680 by50), so in my own simple words, I have 50 sets of 14680 (5*5) matrices. What I would like to do is do the following operation for each matrix: Suppose for a given 5*5 matrix; get sum of 1st column, then the sum of the first row, then compute the difference (Sum of the 1st column minus sum of 1st row) [ Difference=(sum(:,1)-sum(1,:))] Next is basically manipulating the output: Final matrix should be of dimension (14680*50) (each row element contains a value for the difference calculate above) So this matrix is now 2D and I can just plot a curve for each row (change of the difference calculated from 1 to 50) I would greatly appreciate any guidance, Thank you so much, Amine

Respuesta aceptada

the cyclist
the cyclist el 12 de Dic. de 2016
Editada: the cyclist el 12 de Dic. de 2016
I think this does what you describe ...
% Some made-up data
M = rand(5,5,14680,50);
sumCol1 = squeeze(sum(M(:,1,:,:),1));
sumRow1 = squeeze(sum(M(1,:,:,:),2));
diffColRow = sumCol1 - sumRow1;
Also, you don't really need the intermediate variables:
diffColRow = squeeze(sum(M(:,1,:,:),1)) - squeeze(sum(M(1,:,:,:),2));
  1 comentario
Amine Ben Ayara
Amine Ben Ayara el 12 de Dic. de 2016
Mr. Cyclist, You are a life saver! Truly appreciate your help, Happy holidays, Amine

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Calendar 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