您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > 简谐振动的合成及其MATLAB实现
简谐运动的合成及其MATLAB实现班级:理科实验12-3姓名:董林学号:12090312姓名:张国程学号:120903142013.11.202简谐运动的合成及其MATLAB实现董林(70%)张国程(30%)摘要:MATLAB是一款集符号计算、数值分析、图形可视化、模拟仿真等多种功能为一体的科技应用软件。本文应用MATLAB软件,通过编程计算和数值模拟,用一个程序初步解决了平面简谐振动的合成的问题。将简谐振动合成的函数进行了准确的计算和对图形的模拟和分析比较,加深了对其的掌握和理解。关键词:MATLAB应用、简谐振动合成、数值模拟、分析比较Abstract:Waveformsandtrajectoriesofsimpleharmonicvibrationatdifferentfrequenciesatone,twoandthree-dimensionalcoordinatesaremappedbasedonMATLAB,uponwhichthelawsofcompositionofsimpleharmonicvibrationatdifferentfrequenciesareexplored.Keywords:MATLAB;simpleharmonicvibrationatdifferentfrequencies;compositionO、引言MATLAB软件介绍MATLAB将矩阵运算、数值分析、图形处理、编程技术结合在一起,为用户提供了一个强有力的科学及工程问题的分析计算和程序设计工具,它还提供了专业水平的符号计算、文字处理、可视化建模仿真和实时控制等功能,是具有全部语言功能和特征的新一代软件开发平台。简谐振动的合成的背景及意义简谐运动的合成问题在大学物理学习中占有不可忽视的作用,教材中通常讲解解析法和转矢量法。但是这两种方法均存在不足之处:由解析法得到的合成图像方程不直观;旋转矢量法虽直观形象,但准确率欠佳,而且完整作图要花费时间。这给学习带来诸多不便,导致学习效果不佳。如果巧妙地利用MATLAB进行计算机进行辅助学习,问题就会迎刃而解。1.简谐振动合成的理论分析1.1同方向同频率的简谐振动的合成如图所示,设有两个独立的同频率的简谐振动,位移为x1=A1cos(ωt+φ1),x2=A2cos(ωt+φ2)。由于两个振动在同一直线上,因此合振动为x=x1+x2=A1cos(ωt+φ1)+A2cos(ωt+φ2)=(A1cosφ1+A2cosφ2)cosωt-(A1sinφ1+A2sinφ2)sinωt,令Acosφ=A1cosφ1+A2cosφ2,Asinφ=A1sinφ1+A2sinφ2,则x=Acosφcosωt–Asinφsinωt=Acos(ωt+φ),221212212cos(),AAAAA11221122sinsinarctancosos.cAAAA31.2同方向不同频率的简谐振动的合成设一个质点同时参与两个同一直线不同频率的简谐振动,角频率分别为ω1和ω2,为了突出频率不同所产生的效果,设分振动的振幅和初相位都相同,因此两个分振动方程为𝑥1=Acos(ω1t+𝜑1),𝑥2=Acos(ω2t+φ2)利用和差化积公式可得合振动为𝑥=𝑥1+𝑥2=2𝐴cos(ω1−𝜔22t+𝜑1−𝜑22)cos(𝜔1+𝜔22+𝜑1+𝜑22当两个分振动的频率比较大而差异比较小时:|ω2-ω1|ω2+ω1,方程就表示了振幅按2Acos[(ω2-ω1)t/2]变化的角频率为(ω2+ω1)/2的“近似”的简谐振动。1.3相互垂直同频率的两简谐振动的合成设两个同频率的简谐振动分别沿x轴和y轴进行,位移为x=A1cos(ωt+φ1),y=A2cos(ωt+φ2),这就是质点运动的参数方程。将余弦函数展开得x/A1=cosωtcosφ1-sinωtsinφ1,y/A2=cosωtcosφ2-sinωtsinφ2质点的轨迹方程两个互相垂直的同频率简谐振动的合成一般是椭圆,其形状和大小以及两个主轴的方向由振幅A1和A2以及初相差φ2-φ1决定。xsinφ2/A1-ysinφ1/A2=cosωtsin(φ2-φ1)xcosφ2/A1-ycosφ1/A2=sinωtsin(φ2-φ1)22221212212122cos()sin()xyxyAAAA41.4同频率三维简谐运动合成设一个质点沿x轴、y轴z轴的分运动都是简谐运动,而且频率相同。三分运动的表达式分别为x=𝐴1cos(𝜔𝑡+𝜑1)y=𝐴2cos(𝜔𝑡+𝜑2)z=𝐴3cos(𝜔𝑡+𝜑3)上三式联立,消去变量t得x^2/A1^2+y^2/A2^2+z^2/A3^2-xycos(φ2-φ1)/A1A2-yzcos(φ3-φ2)/A2A3-zxcos(φ1-φ3)/A1A3=1/2[sin^2(φ2-φ1)+sin^2(φ3-φ2)+sin^2(φ1-φ3)不同频率的三维简谐振动的简谐振动的合成比较复杂,很难求出其轨迹方程。2.程序代码及实例2.1设计思路创造界面,控制参数输入进入子函数区,进行相应参数的计算函数图像输出函数形式的输出和比较判断degree判断w返回通过维数判断分类52.2程序代码%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%该程序用于处理大学物理中简谐振动合成的相关问题,编写人:董林学号:12090312班级:理科实验12-3时间:2013.11.21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%该程序能够处理简谐振动的两个(一、维)和三个(三维)合成问题,进行原函数及合成表函数的达式的输出和比较及函数图像的输出和比较,将繁琐的分散的分类处理用一个函数完成%%有助于加强MATLAB软件在物理学中的应用和简谐振动合成部分知识的掌握和理解%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%disp('简谐运动的合成的函数与图像')%%%%%%%%%%%%%%%%%%%%%%%%%准备工作,取消参数赋值,清屏%%%%%%%%%%%%%%%%%%%%%%clear;clc;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%化参数输入表格%设计输入赋值函数%%%%%%%%%%%%%%%%%%%%%%%%degree=input('pleaseinputthedegree1/2/3:');t=-4*pi:0.1:4*pi;%设定变量范围%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%定义全局变量globalA1w1fai1A2w2fai2A13w13fai13A23w23fai23A33w33fai33;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%三维处理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%设置参数输入界面ifdegree==3%判断,是则进入三维函数处理部分%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6options={'振动振幅A1','角速度w1','振动初相位fai1',...'振动振幅A2','竖角速度w2','振动初相位fai2','振动振幅A1','角速度w1','振动初相位fai1',};topic='空间简谐振动振动合成';lines=1;def={'0','0','0','0','0','0','0','0','0'};%初始显示值h=inputdlg(options,topic,lines,def);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%参数输入控制%%%%%%%%%%%%%%%%%%%%%%%%%%%A13=eval(h{1});w13=eval(h{2});fai13=eval(h{3})*pi/180;A23=eval(h{4});w23=eval(h{5});fai23=eval(h{6})*pi/180;A33=eval(h{4});w33=eval(h{5});fai33=eval(h{6})*pi/180;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%参变量和函数的计算%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%x=A13*cos(w13*t+fai13);y=A23*cos(w23*t+fai23);z=A33*cos(w33*t+fai33);subplot(2,3,1);plot(x);title('函数1');subplot(2,3,2);plot(y);title('函数2');subplot(2,3,3);plot(z);title('函数3');subplot(2,3,[456]);plot3(x,y,z);title('合成函数');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%7%%%%%%%%%%%%%%%%%%%%%%图像输出disp('函数1:');iffai13==0disp(['x1=',int2str(A13),'*cos(',int2str(w13),'*t)']);elsedisp(['x1=',int2str(A13),'*cos(',int2str(w13),'*t+',int2str(fai13),'*П)']);enddisp('函数2:');iffai23==0disp(['x2=',int2str(A23),'*cos(',int2str(w23),'*t)']);elsedisp(['x2=',int2str(A23),'*cos(',int2str(w23),'*t+',int2str(fai23),'*П)']);endiffai33==0disp(['x2=',int2str(A33),'*cos(',int2str(w33),'*t)']);elsedisp(['x2=',int2str(A33),'*cos(',int2str(w33),'*t+',int2str(fai33),'*П)']);endi
本文标题:简谐振动的合成及其MATLAB实现
链接地址:https://www.777doc.com/doc-1780187 .html