# How to make a curve smooth in spline block

5 ビュー (過去 30 日間)
dk2507 2017 年 2 月 28 日
コメント済み: Massimo Zanetti 2017 年 2 月 28 日
Hi, i need to make a cam model in simulink so i use a spline block to model the curve.Here is my code:
clear
clc
s=0:0.005:1;i=0;
for t1=0:0.005:0.125;
i=i+1;
s(i)=(pi*t1-0.25*sin(4*pi*t1))/(pi+4);
end
for t2=0.130:0.005:0.875;
i=i+1;
s(i)=(2+pi*t2-(9/4)*sin((pi+4*pi*t2)/3))/(pi+4);
end
for t3=0.880:0.005:1
i=i+1;
s(i)=(4+pi*t3-0.25*sin(4*pi*t3))/(pi+4);
end
T=0:0.005:1;
% plot(T,s);
r=1:1:21;n=0;
for m=1:5:201
n=n+1;
end
th=60:(110/40):170;
% figure(2);
th2=170:0.5:190;
th3=300:(-110/40):190;
x3=fliplr(x3);
y3=fliplr(y3);
th4=-60:5:60;
x=[x1,x2,x3,x4];
x=x';
y=[y1,y2,y3,y4];
y=y';
% subplot(5,3,1);
% plot(x,y);
% axis([-150,150,-150,150]);
CAM=[x,y]; But the curve is not smooth,please tell me what is the problem.

サインインしてコメントする。

### 回答 (1 件)

Massimo Zanetti 2017 年 2 月 28 日
If you want to approximate a set of points by a smooth curve you need a smoothing spline, not just a spline. Moreover, in your case you need the smoothing spline to be a closed curve, therefore with periodic conditions.
I have done a function to do exactly that, check it out:
##### 4 件のコメント表示非表示 3 件の古いコメント
Massimo Zanetti 2017 年 2 月 28 日