单摆在MATLAB中的应用Word下载.docx
《单摆在MATLAB中的应用Word下载.docx》由会员分享,可在线阅读,更多相关《单摆在MATLAB中的应用Word下载.docx(14页珍藏版)》请在冰豆网上搜索。
总能量是单摆开始摆动时给定的。
令,这是单摆的最大势能。
由上述公式我们知道,角速度关于摆角是周期变化的,周期为,即单摆的动能随着摆角的变化而周期变化的。
二、利用MATLAB处理单摆的相关问题
1、运用Matlab语言制作单摆%挂摆横梁%bydynamic%seealsohttp:
//www、matlabskyZZZ%xx、6、9h=figure('
numbertitle'
'
off'
name'
擦除动画演示(挂摆横梁)Matlabsky'
)
%绘制横梁plot([-0、2;
0、2],[0;
0],'
-k'
linewidth'
20);
%画初始位置的单摆g=0、98;
%重力加速度,可以调节摆的摆速l=1;
%摆长theta0=pi/4;
%初始角度x0=l*sin(theta0);
%初始x坐标y0=-l*cos(theta0);
%初始y坐标axis([-0、75,0、75,-
1、25,0]);
axisoff%创建摆锤%擦除模式为xorhead=line(x0,y0,'
color'
r'
linestyle'
、'
erasemode'
xor'
markersize'
40);
%创建摆杆body=line([0;
x0],[-0、05;
y0],'
b'
-'
);
%摆的运动t=0;
%时间变量dt=0、01;
%时间增量while1t=t+dt;
theta=theta0*cos(sqrt(g/l)*t);
%单摆角度与时间的关系x=l*sin(theta);
y=-l*cos(theta);
if~ishandle(h),return,endset(head,'
xdata'
x,'
ydata'
y);
%改变擦除对象的坐标数据set(body,'
[0;
x],'
[-0、05;
y]);
drawnow;
%刷新屏幕运行结果如图2所示:
图2单摆的模型h=
12、研究单摆周期与摆长之间的关系程序如下:
l=1:
0、1:
2;
%摆长的变化范围g=
9、8;
%当地的重力加速度t=2*pi*sqrt(l/g)
%周期的计算公式运行结果如下:
t=Columns1through7
2、0071
2、1051
2、1987
2、2884
2、3748
2、4582
2、5388Columns8through1
12、6169
2、6928
2、7666
2、838
53、对单摆水平和垂直方向的分力的研究假设单摆的各个量如下:
初始角速度300度/秒,摆与水平夹角30度,杆长0、45米,小球质量2kg。
程序如下:
theta0=-0、524;
%最初的角度w=-
5、24;
%角速度m=
2、0;
%摆球质量L=0、45;
%摆长g=
%当地重力加速度t=0:
0、01:
2;
%时间的变化范围theta=theta0+w*t;
%t时刻所对应的角度fx=m*w*w*L*cos(theta)
%垂直方向的分量fy=m*w*w*L*sin(theta)+m*g%水平方向的分量运行结果如下:
fx=Columns1through7
21、3961
20、7192
19、9853
19、1966
18、3552
17、4634
16、5237Columns8through14
15、5386
14、5108
13、4432
12、3387
11、2004
10、0313
8、8346Columns15through2
17、6137
6、3719
5、1127
3、8393
2、5555
1、264
61、32403、898
16、429
48、8902Columns29through35-
10、0856
12、3903
14、5589
16、5678Columns36through42-
17、5054
19、2340
20、7515
22、0413Columns43through49-
22、5963
23、5188
24、1833
24、5824Columns50through56-
24、6810
24、6747
24、3977
23、8530Columns57through63-
23、4821
22、5479
21、3663
19、9503Columns64through70
19、1591
17、4212
15、4923
13、3933Columns71through77-
12、287
29、976
97、557
15、0544Columns78through84-
3、780
61、20520、0892
1、3834
2、6738
3、9568Columns85through9
15、2290
6、4868
7、7268
8、9457
10、1399
11、3063
12、4417Columns92through98
13、5429
14、6070
15、6309
16、6119
17、5474
18、4346
19、2713Columns99through105
20、0551
20、7838
21、4554
22、0682
22、6203
23、1104
23、5370Columns106through112
23、8991
24、1955
24、4255
24、5884
24、6839
24、7116
24、6714Columns113through119
24、5635
24、3882
24、1460
23、8374
23、4635
23、0251
22、5235Columns120through126
21、9600
21、3363
20、6541
19、9151
19、1214
18、2753
17、3790Columns127through133
16、4350
15、4459
14、4143
13、3432
12、2355
11、0942
9、9224Columns134through1408、7234
7、5005
6、2569
4、9962
3、7218
2、4371
1、1458Columns141through147-0、148
72、732
95、287
17、7833Columns148through154-
9、0011
11、3592
13、5926
15、6769Columns155through161-
16、6559
18、4742
20、0898
21、4849Columns162through168-
22、0949
23、1314
23、9141
24、4344Columns169through175-
24、5943
24、7112
24、5569
24、1332Columns176through182-
23、8217
23、0034
21、9327
20、6213Columns183through189-
19、8798
18、2352
16、3905
14、3660Columns190through196-
13、2931
11、04108、667
76、1993Columns197through201-
4、937
92、377
90、402
81、81102、984
33、909
74、577
24、979
45、1118Columns22through28-
5、076
34、802
54、260
83、4573Columns29through35-
2、96001、781
20、36780、4222
1、2647Columns36through4
22、1577
3、0985
4、0846
5、1133
6、1817
7、2870
8、4261Columns43through4
99、5959
10、7931
12、0146
13、2568
14、5164
15、7900
17、0741Columns50through56
18、3651
19、6595
20、9537
22、2442
23、5275
24、7999
26、0581Columns57through63
27、2986
28、5179
29、7128
30、8799
32、0160
33、1180
34、1829Columns64through70
35、2078
36、1899
37、1264
38、0148
38、8527
39、6377
40、3676Columns71through77
41、0406
41、6548
42、2083
42、6999
43、1280
43、4915
43、7894Columns78through84
44、0209
44、1854
44、2824
44、3117
44、2731
44、1668
43、9930Columns85through91
43、7523
43、4453
43、0728
42、6358
42、1357
41、5737
40、9513Columns92through98
40、2704
39、5327
38、7403
37、8953
37、0001
36、0572
35、0691Columns99through105
34、0385
32、9683
31、8613
30、7208
29、5497
28、3512
27、1288Columns106through112
25、8857
24、6253
23、3512
22、0667
20、7755
19、4810
18、1869Columns113through119
16、8966
15、6138
14、3419
13、0845
11、8449
10、6266
9、4330Columns120through12
68、2672
7、1326
6、0322
4、9691
3、9461
2、9661
2、0317Columns127through13
31、14560、310
11、199
82、481
53、520
94、306
64、83005、0853Columns141through147-
5、111
44、960
34、539
63、8541Columns148through154-
3、414
22、346
41、0377q*y
(2)-sin(y
(1))+b*cos(w0*t)];
%对角速度微分ts=linspace(0,5,100);
%对ts赋值
[t,y]=ode45(fun,ts,[0,2]);
%在此区域生成网格坐标y1=y(:
1);
%摆角y2=y(:
2);
%角速度y2i=y2(abs(y1-
1、59)<
0、048);
%b的约束条件bdata=
[bdata;
b*ones(size(y2i))];
y2data=
[y2data;
y2i];
endplot(bdata,y2data,'
*-'
%绘制曲线xlabel('
)ylabel('
角速度'
)运行结果如图3所示:
图3角速度与常数b的关系
5、单摆的二阶性程序如下:
%单摆系统,要考虑空气阻力,以及出示状态,经过数学分析,该系统是一个二阶系统%什么是二阶系统,就是有两个状态变量(可以进行微分的)g=
%当地重力加速度T=15;
%该单摆的周期dt=0、0001;
%时间的变化间隔t=0:
dt:
T;
%给时间t赋值L=1;
%摆长m=10;
%摆锤K=5;
v0=0;
%初速度赋值theta0=
3、1;
v=zeros(size(t));
%存储变量初始化theta=zeros(size(t));
%变量初始化v
(1)=v0;
theta
(1)=theta0;
%赋初值fork=1:
length(t)%开始仿真二阶方程组描述系统运行v(k+1)=v(k)+(g*sin(theta(k))-K、/m、*v(k))、*dt;
theta(k+1)=theta(k)-
1、/L、*v(k)、*dt;
end[AX,H1,H2]=plotyy(t,v(1:
length(t)),t,theta(1:
length(t)),'
plot'
set(H1,'
LineStyle'
%设置作图类型,前者实线后者虚线set(H2,'
-、'
%设置作图类型,前者实线后者虚线set(get(AX
(1),'
Ylabel'
),'
string'
线速度v(t)
m/s'
%设置y轴的标注set(get(AX
(2),'
角位移theta(t)
rad/s'
xlabel('
时间t/s'
legend(H1,'
线速度v(t)'
%说明曲线1名称legend(H2,'
角位移theta(t)'
%说明曲线2名称结果如图4所示:
图4单摆的二阶性
三、结论
1、利用Matlab语言制作单摆,可以看到一个动态的单摆运动,使人更加清晰,便捷的看到一幅动态的画面,便于理解。
2、从运行结果可以看出:
随着摆长的增加周期也随之增大。
即:
摆长与周期成正比例关系。
3、单摆的水平分量和竖直分量随着摆角的变化而变化,当单摆角为0度时,竖直分量为0;
当摆角为90度时,水平分量为0。
4、角速度与摆角有一定的关系,当给定一个摆角时,就会有一个角速度与之对应。
结果应该是角速度随b线性增加。
5、运用Matlab语言研究单摆的二阶性,就是对两个状态变量进行微分的,可以使繁琐的运算量变得简洁明了,运行结果清晰可见。
四、课程体会本课程开始讲的是一些matlab的入门技术,除了一些基本操作与介绍之外,还初步认识了简单指令的编制,认识了一些matlab的特殊符号,例如运算用到的加减乘除。
(+
38、4、刘卫国、科学计算与MATLAB语言[M]、北京:
中国铁道出版社,2000、5、张志涌、精通MATLAB
6、5[M]、北京:
北京航空航天大学出版社,2003、6、易德文,盛忠志、利用单摆测重力加速度时的最大摆角的再讨论[J]、物理实验,2003;
23(7):
44
36、8、贾利群、物理实验学[M]_北京:
东方出版社,1999:
103、