Plot a circle using centre point and radius in MATLAB
Last Updated :
08 Apr, 2019
The aim is to plot a circle using center point and radius in MATLAB without using inbuilt functions for plotting. A black and white image can be represented as a 2 order matrix. The first order is for the rows and the second order is for the columns, the pixel value will determine the color of the pixel based on the grayscale color format.
Approach :
Below is the implementation:
I=zeros(300, 600)+1;
R=50;
c=300;
r=150;
for i=1:size(I, 1)
for j=1:size(I, 2)
dist=round(sqrt((j-c)^2+(i-r)^2));
if dist==R
I(i, j)=0;
end
end
end
figure, imshow(I);
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...