필터 지우기
필터 지우기

Matrix Manipulation from 4D to 3D

조회 수: 2 (최근 30일)
Amine Ben Ayara
Amine Ben Ayara 2016년 12월 12일
댓글: Amine Ben Ayara 2016년 12월 12일
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

채택된 답변

the cyclist
the cyclist 2016년 12월 12일
편집: the cyclist 2016년 12월 12일
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
Amine Ben Ayara
Amine Ben Ayara 2016년 12월 12일
Mr. Cyclist, You are a life saver! Truly appreciate your help, Happy holidays, Amine

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by