save values of 2D matrix into a multidimensional matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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 Center 및 File Exchange에서 Frequency Transformations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!