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!