How to create bins that are then used to create surf function

1 vue (au cours des 30 derniers jours)
jgillis16
jgillis16 le 22 Juin 2015
Commenté : Star Strider le 23 Juin 2015
I am trying to create a scatter plot that plots the right ascension against the declination and puts them into 1 degree bins. I have a file and code already that breaks down and takes the right ascension and declination into respective degree variables.
Below is the code:
load GWGCCatalogrm.txt %loads text into workspace
readCatalog( GWGCCatalogrm )
fid = fopen( 'GWGCCatalogrm.txt');
trashLine = fgets(fid); %Skips the first line
data = textscan(fid, '%f%s%f%f%s%f%f%f%f%f%f%f%f%f%f%f%f%f', 'Delimiter', '|', 'TreatAsEmpty','~');
fclose(fid);
GalList.pgc = data{1};
GalList.name = data{2};
GalList.ra = data{3};
GalList.dec = data{4};
GalList.major = data{7};
GalList.abs_mag = data{14};
GalList.dist = data{15};
GalList.ra = GalList.ra.*15;
GalList.dec = GalList.dec ;
GalaxyList = GalList;
C1 = GalList.ra;
S1 = GalList.dec;
c=linspace(-6,10,length(C1));
load NewGalaxy.txt
readCatalog( NewGalaxy )
fid = fopen( 'NewGalaxy.txt');
trashLine = fgets(fid); %Skips the first line
data = textscan(fid, '%f%s%f%f%s%f%f%f%f%f%f%f%f%f%f%f%f%f', 'Delimiter', '|', 'TreatAsEmpty','~');
fclose(fid);
GalList.pgc = data{1};
GalList.name = data{2};
GalList.rad = data{3};
GalList.decd = data{4};
GalList.major = data{7};
GalList.abs_mag = data{14};
GalList.dist = data{15};
GalList.rad = GalList.rad.*15;
GalList.decd = GalList.decd ;
GalaxyList = GalList;
D1 = GalList.rad;
F1 = GalList.decd;
s=linspace(-6,10,length(D1));
scatter(C1,S1,[],c,'filled')
hold on
scatter(D1,F1)
colorbar
xlim([0 350])
ylim([-90 90])
My files are attached. Thank you!

Réponse acceptée

Star Strider
Star Strider le 22 Juin 2015
If your data are in fractional degrees, you can use round, fix or their friends to force them into integer degrees.
(I read your earlier post, but couldn’t figure out what you intend by ‘bin’. To me, that infers a histogram, but I then can’t figure out if you want the sum of the numbers of galaxies in a particular interval, and how you want to do that in the context of a 2D scatterplot.)
  26 commentaires
jgillis16
jgillis16 le 23 Juin 2015
It looks like the 2D plot I produced before attempting this in 3D. This is what I was looking for in terms of binning (the colors are something I have to revise from my side by extracting the color completeness from a few catalogs. It was a nice attempt and I will look further into it.)
Again, thank you so much Star! My questions are done (for now :) ).
Star Strider
Star Strider le 23 Juin 2015
My pleasure!
I searched through the documentation for accumarray and also hist3. Neither provides an index map from the original data to the histogram information. The nested loops would likely work if you have something else you need to do while they’re running, but that also requires that you first decide on how to handle different values of data{5} (e.g. mean, median, sum, product, something else, or simply accumulating them as part of a cell array) for each bin. I have no idea how the galaxies’ sky positions relate to data{5}. If they’re closely correlated, that might not be a problem. It’s something to think about in the interim.
I’ve reserved a specific section of my archive file for your galaxy work, with their URLs, so they all have a context!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by