How to create nested loops to create surf function

1 vue (au cours des 30 derniers jours)
jgillis16
jgillis16 le 23 Juin 2015
Modifié(e) : jgillis16 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;
C12 = round(C1)
S12 = round(S1)
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])
From previous posts, I had to separate the galaxies with values defined in column 5 within 20 Mpc from the galaxies with no values defined in column 5 within 20 Mpc. Now, I need to make a surf plot that uses 2 matrices consisting of one matrix with the galaxies with classification (GWGCCatalogrm) and the other matrix will be without the classification with the galaxies (NewGalaxy) that is divided by one degree each 'bin' so that in each 1 degree of the surf plot I could count how many galaxies are within that 1 degree.
Side note: From the two matrices, we will need the RA and DEC so --> RA = M(:,3) DEC = M(:,4)
We will need counts that share specific RA and DEC values (so that all that have RA = 30° and Asc = 15° are summed, for instance).
I was wondering how I would write three nested for loops for this?
Any help will be appreciated!

Réponses (0)

Catégories

En savoir plus sur Data Import and Export 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