用matlab以动画的方式绘制出摆线 x=a(t-sint) y=a(1-cost) (a自己赋值)的渐屈线

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/08 06:27:52
用matlab以动画的方式绘制出摆线x=a(t-sint)y=a(1-cost)(a自己赋值)的渐屈线用matlab以动画的方式绘制出摆线x=a(t-sint)y=a(1-cost)(a自己赋值)的渐

用matlab以动画的方式绘制出摆线 x=a(t-sint) y=a(1-cost) (a自己赋值)的渐屈线
用matlab以动画的方式绘制出摆线 x=a(t-sint) y=a(1-cost) (a自己赋值)的渐屈线

用matlab以动画的方式绘制出摆线 x=a(t-sint) y=a(1-cost) (a自己赋值)的渐屈线
clear;
clc;
close;
a=1;
syms t
x=a*(t-sin(t));
y=a*(1-cos(t));
ezplot(x,y,[0,2*pi]),grid on;hold on;
dy=diff(y)/diff(x);
dyy=diff(dy)/diff(x);
xx=x-(1+dy^2)*dy/dyy;%渐屈线的坐标
yy=y+(1+dy^2)/dyy;
M=50;
t=0;
xxx=subs(xx);
yyy=subs(yy);
H1=plot(xxx,yyy,'r');hold on;grid on;axis([0,7,-2.5,2.5]);
x1=subs(x);
y1=subs(y);
H2=plot([x1,xxx],[y1,yyy],'k--');
H3=plot(x1,y1,'ko');
H4=plot(xxx,yyy,'ro');
tt=linspace(0,2*pi,M);
for i=1:M
pause(0.2);
t=tt(1:i);
xxx=subs(xx);
yyy=subs(yy);
x1=subs(x);
y1=subs(y);
set(H1,'xdata',xxx,'ydata',yyy);
set(H2,'xdata',[x1(i),xxx(i)],'ydata',[y1(i),yyy(i)]);
set(H3,'xdata',x1(i),'ydata',y1(i));
set(H4,'xdata',xxx(i),'ydata',yyy(i));
end

clear all;clf
a=1;
t=(1:720)./180*pi;
x=a*(t-sin(t));
y=a*(1-cos(t));
plot(x,y,'k-');hold on
t1=t+pi;
x1=a*(t1-sin(t1))-pi;
y1=a*(-1-cos(t1));
plot(x1,y1,'g:')
...

全部展开

clear all;clf
a=1;
t=(1:720)./180*pi;
x=a*(t-sin(t));
y=a*(1-cos(t));
plot(x,y,'k-');hold on
t1=t+pi;
x1=a*(t1-sin(t1))-pi;
y1=a*(-1-cos(t1));
plot(x1,y1,'g:')
for i=1:length(t)
h0=plot(x(i),y(i),'ko');
h1=plot(x1(i),y1(i),'ro');
h2=plot([x(i) x1(i)],[y(i) y1(i)],'b-');
pause(0.01);
delete(h0);
delete(h1);
delete(h2);
if i>1
plot(x1(i-1:i),y1(i-1:i),'r-')
end
end

收起