save values of 2D matrix into a multidimensional matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
J. Alex Lee
am 28 Sep. 2022
Bearbeitet: J. Alex Lee
am 28 Sep. 2022
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);
Antworten (0)
Siehe auch
Kategorien
Mehr zu Frequency Transformations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!