필터 지우기
필터 지우기

save values of 2D matrix into a multidimensional matrix

조회 수: 2 (최근 30일)
Mikel
Mikel 2022년 9월 26일
편집: J. Alex Lee 2022년 9월 28일
Hello,
I have a for loop where a I generates two new points in every loop for my 2xn matrix where n=15001.
I want to save values from this matrix that meets 4 conditions into m different 2 x k matrixes (sizes are not the same for each matrix) where m=221. Maybe I need to use cells but I'm having issues when creating the nested for loop for this operation, I can not achieve what I'm aiming for, I need help please. Here my code:
for ind2=2:15001
%some previous code that generates points for x1x2 matrix (its long)
% save values of x1d x2d
x1x2(:,ind2)=[x1d(1,ind2);x2d(ind2)];
for indX1=1:16
for indX2=1:12
if (x1x2(1,ind2)>X1(indX1) && x1x2(1,ind2)<X1(indX1+1) && x1x2(2,ind2)>X2(indX2) && x1x2(2,ind2)<X2(indX2+1))
%Here my issue, Im not able to create this
%multidiemnsional matrix
ROIx1x2(:,count,m)= x1x2(:,ind2);
F(count,1,m)= fintd(:,ind2);
count=count +1;
end
end
end
end
  댓글 수: 7
Mikel
Mikel 2022년 9월 28일
Thank you! this is what I was looking for
J. Alex Lee
J. Alex Lee 2022년 9월 28일
편집: J. Alex Lee 2022년 9월 28일
The value of m is static, is it supposed to be something like sub2ind(size(PDLUT),indX1,indX2) or something?
I wonder if what you are looking for ultimately is something like a 2D histogram, or you can extract what you need from it:
histogram2(x1x2(1,:),x1x2(2,:),X1,X2)
[N,XEDGES,YEDGES,BINX,BINY] = histcounts2(x1x2(1,:),x1x2(2,:),X1,X2);

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

답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by