COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### plotting smooth cirle (cirlcular arc)

• Follow

```I want to plot smooth circle in MATLAB
I am doing ti byt following two ways

1)
t = linspace(0,2*pi,10000);
r=7;
x = r*cos(t);
y = r*sin(t);
plot(x,y);

No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc

2)
syms x y
fh = @(x,y) x.^2 + y.^2 - r^2;
ezplot(fh);

None of the above gives me smooth circular arc

Can anyone help me with this?

Thanks
Prashant
```
 0

```"prashant " <iamprashant@gmail.com> wrote in message <ibrpj8\$qvf\$1@fred.mathworks.com>...
> I want to plot smooth circle in MATLAB
> I am doing ti byt following two ways
>
> 1)
> t = linspace(0,2*pi,10000);
> r=7;
>  x = r*cos(t);
>  y = r*sin(t);
>  plot(x,y);
>
> No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc
>
> 2)
> syms x y
> fh = @(x,y) x.^2 + y.^2 - r^2;
> ezplot(fh);
>
> None of the above gives me smooth circular arc
>
> Can anyone help me with this?
>
> Thanks
> Prashant

Hi Prashant, I'm afraid I don't know what you mean. Are you saying that

t = linspace(0,2*pi,10000);
r=7;
x = r*cos(t);
y = r*sin(t);
plot(x,y);

Does not generate a smooth circle for you?

Wayne
```
 0

```"Wayne King" <wmkingty@gmail.com> wrote in message <ibrrsd\$oj\$1@fred.mathworks.com>...
> "prashant " <iamprashant@gmail.com> wrote in message <ibrpj8\$qvf\$1@fred.mathworks.com>...
> > I want to plot smooth circle in MATLAB
> > I am doing ti byt following two ways
> >
> > 1)
> > t = linspace(0,2*pi,10000);
> > r=7;
> >  x = r*cos(t);
> >  y = r*sin(t);
> >  plot(x,y);
> >
> > No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc
> >
> > 2)
> > syms x y
> > fh = @(x,y) x.^2 + y.^2 - r^2;
> > ezplot(fh);
> >
> > None of the above gives me smooth circular arc
> >
> > Can anyone help me with this?
> >
> > Thanks
> > Prashant
>
> Hi Prashant, I'm afraid I don't know what you mean. Are you saying that
>
> t = linspace(0,2*pi,10000);
> r=7;
> x = r*cos(t);
> y = r*sin(t);
> plot(x,y);
>
> Does not generate a smooth circle for you?
>
> Wayne

The plot command simply connects points with a straight line,
so eventually, at some scale, the plot will not look "smooth".

As an alternative, (believe it or not) you can actually
use the rectangle command to draw a circle.

doc rectangle

And look at the Example section.
```
 0

```"someone" <someone@somewhere.net> wrote in message <ibs0nv\$ruh\$1@fred.mathworks.com>...
> "Wayne King" <wmkingty@gmail.com> wrote in message <ibrrsd\$oj\$1@fred.mathworks.com>...
> > "prashant " <iamprashant@gmail.com> wrote in message <ibrpj8\$qvf\$1@fred.mathworks.com>...
> > > I want to plot smooth circle in MATLAB
> > > I am doing ti byt following two ways
> > >
> > > 1)
> > > t = linspace(0,2*pi,10000);
> > > r=7;
> > >  x = r*cos(t);
> > >  y = r*sin(t);
> > >  plot(x,y);
> > >
> > > No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc
> > >
> > > 2)
> > > syms x y
> > > fh = @(x,y) x.^2 + y.^2 - r^2;
> > > ezplot(fh);
> > >
> > > None of the above gives me smooth circular arc
> > >
> > > Can anyone help me with this?
> > >
> > > Thanks
> > > Prashant
> >
> > Hi Prashant, I'm afraid I don't know what you mean. Are you saying that
> >
> > t = linspace(0,2*pi,10000);
> > r=7;
> > x = r*cos(t);
> > y = r*sin(t);
> > plot(x,y);
> >
> > Does not generate a smooth circle for you?
> >
> > Wayne
>
> The plot command simply connects points with a straight line,
> so eventually, at some scale, the plot will not look "smooth".
>
> As an alternative, (believe it or not) you can actually
> use the rectangle command to draw a circle.
>
> doc rectangle
>
> And look at the Example section.

Thanks for the help

I tried plotting circle using rectangle command, it  improved the plot but still circle consists of series of small small lines and not a smooth curve.

I want to paste that circle into word file where it looks jagged and not smooth curve
```
 0

```"prashant" wrote in message <ic13oa\$hpf\$1@fred.mathworks.com>...
> "someone" <someone@somewhere.net> wrote in message <ibs0nv\$ruh\$1@fred.mathworks.com>...
> > "Wayne King" <wmkingty@gmail.com> wrote in message <ibrrsd\$oj\$1@fred.mathworks.com>...
> > > "prashant " <iamprashant@gmail.com> wrote in message <ibrpj8\$qvf\$1@fred.mathworks.com>...
> > > > I want to plot smooth circle in MATLAB
> > > > I am doing ti byt following two ways
> > > >
> > > > 1)
> > > > t = linspace(0,2*pi,10000);
> > > > r=7;
> > > >  x = r*cos(t);
> > > >  y = r*sin(t);
> > > >  plot(x,y);
> > > >
> > > > No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc
> > > >
> > > > 2)
> > > > syms x y
> > > > fh = @(x,y) x.^2 + y.^2 - r^2;
> > > > ezplot(fh);
> > > >
> > > > None of the above gives me smooth circular arc
> > > >
> > > > Can anyone help me with this?
> > > >
> > > > Thanks
> > > > Prashant
> > >
> > > Hi Prashant, I'm afraid I don't know what you mean. Are you saying that
> > >
> > > t = linspace(0,2*pi,10000);
> > > r=7;
> > > x = r*cos(t);
> > > y = r*sin(t);
> > > plot(x,y);
> > >
> > > Does not generate a smooth circle for you?
> > >
> > > Wayne
> >
> > The plot command simply connects points with a straight line,
> > so eventually, at some scale, the plot will not look "smooth".
> >
> > As an alternative, (believe it or not) you can actually
> > use the rectangle command to draw a circle.
> >
> > doc rectangle
> >
> > And look at the Example section.
>
>
> Thanks for the help
>
> I tried plotting circle using rectangle command, it  improved the plot but still circle consists of series of small small lines and not a smooth curve.
>
> I want to paste that circle into word file where it looks jagged and not smooth curve

You cannot make really smooth circle, since every digital image consist of pixels, not dimensionless points. Therefore, you should use small intervals to make it better. Save figure as .png format or another and use in word document. After that scale it smaller. Perhaps, that will do.
```
 0

```"Emre Yilmaz" <emreyilmaz.com@gmail.com> wrote in message
> > > > > I want to plot smooth circle in MATLAB
> > > > > I am doing ti byt following two ways
> > > > >
> > > > > 1)
> > > > > t = linspace(0,2*pi,10000);
> > > > > r=7;
> > > > >  x = r*cos(t);
> > > > >  y = r*sin(t);
> > > > >  plot(x,y);
> > > > >
> > > > > No matter how many points I use to discretize theta it still shows circle as series of lines and not smooth arc
> > > > >
> > > > > 2)
> > > > > syms x y
> > > > > fh = @(x,y) x.^2 + y.^2 - r^2;
> > > > > ezplot(fh);
> > > > >
> > > > > None of the above gives me smooth circular arc
> > > > >
> > > > > Can anyone help me with this?
> > > > >
> > > > > Thanks
> > > > > Prashant
[snip]
> You cannot make really smooth circle, since every digital image consist of pixels, not dimensionless points. Therefore, you should use small intervals to make it better. Save figure as .png format or another and use in word document. After that scale it smaller. Perhaps, that will do.

You are correct in theory, but not in practice. Anti-aliasing (aka line-smoothing) provides a visual effect that makes line-pixelization go away. See http://undocumentedmatlab.com/blog/plot-linesmoothing-property/

Yair Altman
http://UndocumentedMatlab.com

```
 0
Reply altmanyDEL (1123) 5/7/2013 1:31:09 PM

5 Replies
987 Views

Similiar Articles:

7/22/2012 1:55:47 AM