How to get the projection of a 2D colorplot on x axis?

11 visualizaciones (últimos 30 días)
aneps
aneps el 1 de Jun. de 2014
Respondida: Image Analyst el 2 de Jun. de 2014
I have a 2D color plot as following:
how can I choose a region, for example 15 to 25 (axes not labelled in the figure.. the Y axis range from 0 to 40 in this figure) and project on X axis so that I get a 1D histogram? To make clear, the program should sum up the values along Y axis (from yrange 15 to 25) for each X values and then plot SumY against X. This will make a 1D projection of the colormap.
In order to plot the colormap (the above image), I am using the following code:
A=load('Data.dat');
Dat=[Data(:,1) Data(:,2)];
nbins=[100 100];
n=hist3(Dat,nbins);
n1 = n;
n1(size(n,1) + 1, size(n,2) + 1) = 0;
xb = linspace(min(Dat(:,1)),max(Dat(:,1)),size(n,1)+1);
yb = linspace(min(Dat(:,2)),max(Dat(:,2)),size(n,1)+1);
figure
pcolor(xb,yb,n1);
I tried the following:
A1=[A(:,1) A(:,2)];
index= find(A1(:,2)>=15&A1(:,2)<=25);
New=A1(index,:);
vp=sum(New,2);
hist(vp,100)
But along the X axis in the histogram (hist(vp, 100)) it is showing the values from 15 to 65! but in real data (New in the code) it is from 0 to 40 only! something mistake in this code I think!
Thank you

Respuesta aceptada

Image Analyst
Image Analyst el 2 de Jun. de 2014
verticalProjection = sum(theArray, 2); % Sum horizontally along columns in each row.
horizontalProjection = sum(theArray, 1); % Sum vertically along rows in each column.

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by