How to map two data sets on same xy coordinates for density-based comparison (hist3)?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
There are two data sets; dataset-a and dataset-b for an intermediate procedure in a loop. I want to compare these data in terms of density of plots (hist3). The difference is that the dataset-a are distributed on xy dimension of 200x400. Dataset-b are in the zone 120x220 rectangle (shown in 4th figure). The definition of 'bins' in hist3 shows that xy bin of [20 40] means, the effective area is divided into 20 parts horizontally and 40 parts vertically. However, the vicinity of the data change with increase in the number of points also changes. This does not keep the bin size consistent. Is there a way to map these points on a known area (say, 200x and 400y) for both situations and then calculate the densities? That way, the results will also be consistently comparable.
Note: the imagesc command shows inverted image here. It works fine in matlab program.
t = load('data_matlab.mat');
tab = t.ans;
tiledlayout(1,4)
nexttile(1)
box on
plot(tab.ax,tab.ay,'.')
xlim([0 200])
ylim([0 400])
nexttile(2)
box on
resolution = [40 40]; % This defines the how many bins you want 1000mm/10 = 100mm bin size
[n, q] = hist3([tab.ax tab.ay], resolution);
qq = imagesc(q{:}, n');
set(gca, 'YDir','reverse')
xlim([0 200])
ylim([0 400])
nexttile(3)
box on
plot(tab.bx,tab.by,'.')
xlim([0 200])
ylim([0 400])
nexttile(4)
box on
resolution = [40 40]; % This defines the how many bins you want 1000mm/10 = 100mm bin size
[n2, q2] = hist3([tab.bx tab.by], resolution);
qq2 = imagesc(q2{:}, n2');
rectangle('Position',[40 100 120 220],'FaceColor',[0 0 1 0])
set(gca, 'YDir','reverse')
xlim([0 200])
ylim([0 400])
The resulting data set will look like this with consistent bin size (the figure below is only for demonstration). I would appreciate guidance in this regard.
0 commentaires
Réponse acceptée
Bruno Luong
le 5 Oct 2023
Modifié(e) : Bruno Luong
le 5 Oct 2023
Specify edges rather than (resolution) nbins https://www.mathworks.com/help/stats/hist3.html#d126e546264
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!