Drawing a circle with statements

2 views (last 30 days)
mabel
mabel on 24 Jun 2014
Commented: Image Analyst on 24 Jun 2014
Hello everybody:
I think what I want to do is quite easy, but I could not find in internet how to do it. I want to draw a circle by using the statement if:
If x < R
x=1;
end
Later, I want to change x=1 to x equal to the value of a function. Can someone help me? Thank you!

Accepted Answer

mabel
mabel on 24 Jun 2014
Finally I got my own answer.
a=ones(500,500); %matrix size
I= 0.5 %Intesity inside the cirlce
for i=1:500
for j=1:500
if ((j-x)^2+(i-y)^2)<=R^2 %condition to make the cirlce
a(i,j)=I;
end
end
end
imshow(a)

More Answers (1)

Image Analyst
Image Analyst on 24 Jun 2014
  2 Comments
mabel
mabel on 24 Jun 2014
No, it's not at this web. They have another ways to make a circle, but not the one I am asking. I am looking for a matrix with 0, 1, and the 1 make a cirlce.
Image Analyst
Image Analyst on 24 Jun 2014
mabel, it is at that web site -- it was the first example in the FAQ. What you posted as the "Answer" is essentially a for-loop, non-vectorized way of doing the first example in the FAQ. Sorry you didn't recognize that.

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!