フィルターのクリア

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

5 ビュー (過去 30 日間)
aneps
aneps 2014 年 6 月 1 日
回答済み: Image Analyst 2014 年 6 月 2 日
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

採用された回答

Image Analyst
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 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by