Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Smoothing sharp angles of the path

Subject: Smoothing sharp angles of the path

From: Liana

Date: 31 Mar, 2011 03:40:20

Message: 1 of 4

Hello,

there is a simple path specified as follows:
x = [2; 4; 6];
y = [5; 3; 7];
plot(x,y,'--ro');

I'd like to smooth a sharp angle according to some predefined smoothness coefficient. If this coefficient is equal to 0, then the angle is sharp. And if it's equal to 1, then there is just a straight line. What's the best way to implement this task in MATLAB?

P.S. I don't need to fit this path by polynomial, etc.

Thanks.

Subject: Smoothing sharp angles of the path

From: Liana

Date: 31 Mar, 2011 04:14:06

Message: 2 of 4

I've tried the following, but it didn't help. The lines are straight, but not rounded:
x = [2; 4; 6];
y = [5; 3; 7];
yint=interp1(x,y,x,'spline');
plot(x,yint,'--ro');

"Liana" wrote in message <in0t34$mug$1@fred.mathworks.com>...
> Hello,
>
> there is a simple path specified as follows:
> x = [2; 4; 6];
> y = [5; 3; 7];
> plot(x,y,'--ro');
>
> I'd like to smooth a sharp angle according to some predefined smoothness coefficient. If this coefficient is equal to 0, then the angle is sharp. And if it's equal to 1, then there is just a straight line. What's the best way to implement this task in MATLAB?
>
> P.S. I don't need to fit this path by polynomial, etc.
>
> Thanks.

Subject: Smoothing sharp angles of the path

From: Liana

Date: 31 Mar, 2011 04:20:04

Message: 3 of 4

Now it looks a bit similar to what I need:
xx=min(x):0.1:max(x);
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy);

But I would be glad to hear another ideas.

"Liana" wrote in message <in0t34$mug$1@fred.mathworks.com>...
> Hello,
>
> there is a simple path specified as follows:
> x = [2; 4; 6];
> y = [5; 3; 7];
> plot(x,y,'--ro');
>
> I'd like to smooth a sharp angle according to some predefined smoothness coefficient. If this coefficient is equal to 0, then the angle is sharp. And if it's equal to 1, then there is just a straight line. What's the best way to implement this task in MATLAB?
>
> P.S. I don't need to fit this path by polynomial, etc.
>
> Thanks.

Subject: Smoothing sharp angles of the path

From: Liana

Date: 31 Mar, 2011 04:57:05

Message: 4 of 4

Well, I found what I was searching for:
points=[(x)';(y)'];
fnplt(cscvn(points),'-r'); %"Natural" or periodic interpolating cubic spline curve

"Liana" wrote in message <in0vdk$so8$1@fred.mathworks.com>...
> Now it looks a bit similar to what I need:
> xx=min(x):0.1:max(x);
> yy = spline(x,y,xx);
> plot(x,y,'o',xx,yy);
>
> But I would be glad to hear another ideas.
>
> "Liana" wrote in message <in0t34$mug$1@fred.mathworks.com>...
> > Hello,
> >
> > there is a simple path specified as follows:
> > x = [2; 4; 6];
> > y = [5; 3; 7];
> > plot(x,y,'--ro');
> >
> > I'd like to smooth a sharp angle according to some predefined smoothness coefficient. If this coefficient is equal to 0, then the angle is sharp. And if it's equal to 1, then there is just a straight line. What's the best way to implement this task in MATLAB?
> >
> > P.S. I don't need to fit this path by polynomial, etc.
> >
> > Thanks.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us