Hi all,

I can't seem to arrive at my desired result. I got a rectangle instead.

Anyone can share your thoughts ?

Any methods will do as long as the shaded circle appears on this simulated grid matrix a.

Code:

```
# Suppose I have a 200 by 200 matrix with zeros entry
a<- matrix(0,nrow=200,ncol=200)
#I want to draw a shaded circle on this matrix using binary 1 and 0.
# Defining a coordinate as my centre of the circle, e.g.(100,100)
y.cent <- 100
x.cent <- 100
#Suppose I want my radius be 10 unit.
r=10
#I do the following,
xx <- x.cent + r*cos( seq(0,2*pi, length.out=360) )
yy <- y.cent + r*sin( seq(0,2*pi, length.out=360) )
a[xx,yy]=1
image(a)
```

Anyone can share your thoughts ?

Any methods will do as long as the shaded circle appears on this simulated grid matrix a.

Last edited by a moderator: