How to get the projection of a 2D colorplot on x axis?
조회 수: 11 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Image Analyst
2014년 6월 2일
verticalProjection = sum(theArray, 2); % Sum horizontally along columns in each row.
horizontalProjection = sum(theArray, 1); % Sum vertically along rows in each column.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!