Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
help with this loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ok this is basically the code im trying to run. the basic jist is that it calculates the distance to all other points, then compares to a control field, calculates how many points are within that distance (in this case the radius of a circle). With this number i then want to calculate the probability (the final bit of the code after end(k)) this is where the problem is i think. If i individually put in values for i the code works, but im dealing with large data sets and its not really practice to individually in put 1-357 each time. When i run the loop however it doesnt work so im guess my issue is with the loop. can anyone help me out?
rccm = zeros(357,357);
Crccm = zeros(357,2537);
CNccm = zeros(357,2537);
Nccm = zeros(2537,1);
Prob = zeros(357,1);
for i=1:1:357
for j=1:1:357;
rccm(i,j) = sqrt((0.5*(jmag(i,1)-jmag(j,1)).^2)+((diffmag(i,1)-diffmag(j,1)).^2)+((diffmag2(i,1)-diffmag2(j,1)).^2));
hold on
end
srt = sort(rccm); %Put in value of the 15th star
r = transpose(srt(21,1:1:357)); %Radius of the 21 star
for k=1:1:2537;
Crccm(i,k) = sqrt((0.5*(jmag(i,1)-Cfjmag(k,1)).^2)+((diffmag(i,1)-Cfdiffmag(k,1)).^2)+((diffmag2(i,1)-Cfdiffmag2(k,1)).^2));
end
rcontr = transpose(Crccm);
%rcontr1 = sort(rcontr);
CNccm = rcontr(:,i) <= r(i,1); %rcontr = Crccm
Nccm(i) = sum(CNccm(1:2537,1));
Prob(i) = 1-((Nccm(i)/20)*(9/81));
hold on
end
3 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!