12 Jun 2012 @JUAN CARDENAS
n = floor((-1+sqrt(1+8*p))/2);
m=-(n-2*p+n.*(n+1));

Very good solution for using any p but
I think you were missing a '-'sign for your definition of m. (can be seen when plotting the Zernike-Polynomials)

Add the following at the bottom of the MidPoint Circle function to created filled circles
for ii = xc-int16(radius):xc+(int16(radius))
for jj = yc-int16(radius):yc+(int16(radius))
tempR = sqrt((double(ii) - double(xc)).^2 + (double(jj) - double(yc)).^2);
if(tempR <= double(int16(radius)))
i(ii,jj)=value;
end
end
end

This code is extremely useful.
I'm not particularly good in using matlab but i had no trouble understanding how to use it (although it took me a good FIVE minutes).
So Five stars for sure for doing EXACTLY what it says on the box, nothing more and nothing less. You guys should be ashamed for rating less then 5 stars.
For others, to get rid of the gaps I used
FilteredResult=medfilt2(Result, [3 3])
This is how I used this code
(you will now notice i'm no good at matlab)
GGG(1:355,1:355)=0;
xxx(1:355,1:355)=0;
y=rand(1,150);
y=y*50
jj=1;
for j=1:150;
AAA=MidpointCircle(xxx,j,177,177,y(1,jj));
GGG=AAA+GGG;
jj=jj+1;
end;
GGG=medfilt2(GGG, [3 3])
image (GGG)

this is a coding to draw a circle.
i using the same code but i looping it with reduce the radius.
let say, my radius is 7, I try looping it by draw radius with 7, and then 6, and then 5 and so on until it become 0. It really fill in a lot of space but the problem is still got some space is empty.
My problem now is I want to fill in all the area inside the circle. So, any idea to solve this problem? Thank you

Comment only