function sanciquxian
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%三次曲线型
x1=-5:0.001:5;
y1=x1.^3;
subplot(2,2,1);
plot(x1,y1);
title('(a) 含拐点的光滑曲线 y=ax^3(a=1)');
xlabel('x');
ylabel('y');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%抛物线形
x2=-5:0.001:5;
y2=x2.^2;
subplot(2,2,2);
plot(x2,y2);
title('(b) 凹凸型光滑曲线 y=bx^2(b=1)');
xlabel('x');
ylabel('y');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%斜率不为0的直线
x3=-5:0.001:5;
y3=x3;
subplot(2,2,3);
plot(x3,y3);
title('(c) 斜率不为0的直线型光滑曲线 y=cx(c=1)');
xlabel('x');
ylabel('y');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%斜率为0的直线
x4=-5:0.001:5;
y4=ones(size(x4));
subplot(2,2,4);
plot(x4,y4);
title('(d) 斜率为0的直线型光滑曲线 y=d(d=1)');
xlabel('x');
ylabel('y');
end
function fangzhen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 1
a=0.05;
b=0.1;
c=0.1;
d=1;
e=0.05;
%三次曲线型
x11=-5:0.001:-3;
y11=a*x11.^3+b*x11.^2+c*x11+d;
subplot(2,2,1);
plot(x11,y11);
x12=3:0.001:5;
y12=e*x12.^4+a*x12.^3+b*x12.^2+c*x12+d;
hold on;
plot(x12,y12);
%title('(a) two matching broken boundaries');
title('(a) 原图');
xlabel('x');
ylabel('y');
x111=a*(-3)^3+b*(-3)^2+c*(-3)+d;
x112=e*(-3)^4+a*(3)^3+b*(3)^2+c*(3)+d;
plot(-3,x111,'*','MarkerEdgeColor','k');
plot(3,x112,'*','MarkerEdgeColor','k');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 2
x11=-5:0.001:-3;
y11=a*x11.^3+b*x11.^2+c*x11+d;
subplot(2,2,2);
plot(x11,y11);
x12=3:0.001:5;
y12=e*x12.^4+a*x12.^3+b*x12.^2+c*x12+d;
hold on;
plot(x12,y12);
%title('(b) simple connection');
title('(b) 直线路径连接');
xlabel('x');
ylabel('y');
x111=a*(-3)^3+b*(-3)^2+c*(-3)+d;
x112=e*(-3)^4+a*(3)^3+b*(3)^2+c*(3)+d;
plot(-3,x111,'*','MarkerEdgeColor','k');
plot(3,x112,'*','MarkerEdgeColor','k');
a1=(x112-x111)/(6);
b1=x111-a1*(-3);
x11=-3:0.001:3;
y11=a1*x11+b1;
plot(x11,y11);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 3
x11=-5:0.001:-3;
y11=a*x11.^3+b*x11.^2+c*x11+d;
subplot(2,2,3);
plot(x11,y11);
x12=3:0.001:5;
y12=e*x12.^4+a*x12.^3+b*x12.^2+c*x12+d;
hold on;
plot(x12,y12);
%title('(c) use 4 sampling points for connection');
title('(c) 4点采样路径连接');
xlabel('x');
ylabel('y');
x111=a*(-3)^3+b*(-3)^2+c*(-3)+d;
x112=e*(3)^4+a*(3)^3+b*(3)^2+c*(3)+d;
x121=a*(-3.5)^3+b*(-3.5)^2+c*(-3.5)+d;
x122=e*(3.5)^4+a*(3.5)^3+b*(3.5)^2+c*(3.5)+d;
plot(-3,x111,'*','MarkerEdgeColor','k');
plot(3,x112,'*','MarkerEdgeColor','k');
plot(-3.5,x121,'*','MarkerEdgeColor','k');
plot(3.5,x122,'*','MarkerEdgeColor','k');
jie0=[(-3.5)^3 (-3.5)^2 (-3.5) 1;...
(-3)^3 (-3)^2 (-3) 1;...
(3)^3 (3)^2 (3) 1;...
(3.5)^3 (3.5)^2 (3.5) 1;];
jie1=inv(jie0);
jie2=jie1*[x121 x111 x112 x122]';
x11=-3:0.001:3;
y11=jie2(1)*x11.^3+jie2(2)*x11.^2+jie2(3)*x11+jie2(4);
subplot(2,2,3);
plot(x11,y11);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4
x11=-5:0.001:-3;
y11=a*x11.^3+b*x11.^2+c*x11+d;
subplot(2,2,4);
plot(x11,y11);
x12=3:0.001:5;
y12=e*x12.^4+a*x12.^3+b*x12.^2+c*x12+d;
hold on;
plot(x12,y12);
%title('(d) use 6 sampling points for connection');
title('(d) 6点采样路径连接');
xlabel('x');
ylabel('y');
x111=a*(-3)^3+b*(-3)^2+c*(-3)+d;
x112=e*(3)^4+a*(3)^3+b*(3)^2+c*(3)+d;
x121=a*(-3.5)^3+b*(-3.5)^2+c*(-3.5)+d;
x122=e*(3.5)^4+a*(3.5)^3+b*(3.5)^2+c*(3.5)+d;
x131=a*(-4)^3+b*(-4)^2+c*(-4)+d;
x132=e*(4)^4+a*(4)^3+b*(4)^2+c*(4)+d;
plot(-3,x111,'*','MarkerEdgeColor','k');
plot(3,x112,'*','MarkerEdgeColor','k');
plot(-3.5,x121,'*','MarkerEdgeColor','k');
plot(3.5,x122,'*','MarkerEdgeColor','k');
plot(-4,x131,'*','MarkerEdgeColor','k');
plot(4,x132,'*','MarkerEdgeColor','k');
jie0=[(-3.5)^3 (-3.5)^2 (-3.5) 1;...
(-3)^3 (-3)^2 (-3) 1;...
(3)^3 (3)^2 (3) 1;...
(3.5)^3 (3.5)^2 (3.5) 1;...
(-4)^3 (-4)^2 (-4) 1;...
(4)^3 (4)^2 (4) 1];
jie1=inv(jie0'*jie0);
jie2=jie1*jie0'*[x121 x111 x112 x122 x131 x132]';
x11=-3:0.001:3;
y11=jie2(1)*x11.^3+jie2(2)*x11.^2+jie2(3)*x11+jie2(4);
plot(x11,y11);