• kisssinger
    了解作者
  • matlab
    开发工具
  • 84KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2019-11-19 15:39
    上传日期
利用matlab实现了单波方程传播的模拟,该程序适合初学者学习数值离散的问题,是经典的例子。
NHT.zip
  • NHT
  • Shock.m
    955B
  • 0.0315.jpg
    127.6KB
  • main.m
    11B
  • 发散.jpg
    54.5KB
  • project1.m
    1.4KB
  • wave.m
    15.6KB
内容介绍
clc clear all; n=0; x=[-10:0.05:10]; for i=-10:0.05:10%初始点坐标的分布 n=n+1; if(i>=-0.5&&i<0) Wave_U(1,n)=sqrt(3)*i+sqrt(3)/2; %坐标点的y方向坐标 elseif (i>=0&&i<=0.5) Wave_U(1,n)=-sqrt(3)*i+sqrt(3)/2;%坐标点的y方向坐标 else Wave_U(1,n)=0; end if(i<=0) Shock_U(1,n)=1.0; else Shock_U(1,n)=0.0; end if(i<=0) rarefaction(1,n)=0.0; else rarefaction(1,n)=1.0; end end diagram=input("select initial data:triangle(1),shock(2),rarefaction(3)"); switch diagram %选择不同的初始点 case(1) equation=input("select equation:wave(1),heat(2),burger(3)"); %选择要计算的方程 switch equation case(1) DT=0.02;%Δt C=2;%c method=input("select method:\nEuler explicit Mehods(1),Upstream Differencing Method(2),Second Order Upwind Method(3),\nLeap Frog(4),Lax-Wendroff(5),MacCormac(6)"); %选择有限差分的方法 switch method case(1)%Euler explicit Mehods for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)-(C*DT/0.05)*(Wave_U(t-1,i+1)-Wave_U(t-1,i));%wave equation_Euler Explicit Method elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end case(2)%Upstream Differencing Method for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)-(C*DT/0.05)*(Wave_U(t-1,i)-Wave_U(t-1,i-1));%Upstream Differencing Method elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end case(3)%Second Order Upwind Method for t=2:200 for i=1:n if(i>=2&&i<=n-1) Ave_U(t,i)=Wave_U(t-1,i)-(C*DT/0.05)*(Wave_U(t-1,i)-Wave_U(t-1,i-1));%wave equation_Upstream Differencing Method Wave_U(t,i)=0.5*(Wave_U(t-1,i)+Ave_U(t,i)-(C*DT/0.05)*(Ave_U(t,i)-Ave_U(t,i-1))-(C*DT/0.05)*(Wave_U(t-1,i)-Wave_U(t-1,i-1))); elseif(i==1) Ave_U(t,1)=Wave_U(t-1,1); Wave_U(t,1)=Wave_U(t-1,1); else Ave_U(t,n)=Wave_U(t-1,n); Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end case(4)%Leap Frog Method for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)-(C*DT/0.05)*(Wave_U(t-1,i+1)-Wave_U(t-1,i-1)); elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end case(5)%Lax-Wendroff Method for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)-(0.5*C*DT/0.05)*(Wave_U(t-1,i+1)-Wave_U(t-1,i))+(2*(0.5*C*DT/0.05)^2)*(Wave_U(t-1,i+1)-2*Wave_U(t-1,i)+Wave_U(t-1,i-1)); elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end case(6)% MacCormac Method for t=2:200 for i=1:n if(i>=2&&i<=n-1) Ave_U(t,i)=Wave_U(t-1,i)-(C*DT/0.05)*(Wave_U(t-1,i+1)-Wave_U(t-1,i)); Wave_U(t,i)=0.5*(Wave_U(t-1,i)+Ave_U(t,i)-(C*DT/0.05)*(Ave_U(t,i)-Ave_U(t,i-1))); elseif(i==1) Ave_U(t,1)=Wave_U(t-1,1)-(C*DT/0.05)*(Wave_U(t-1,2)-Wave_U(t-1,1)); Wave_U(t,1)=Wave_U(t-1,1); else Ave_U(t,n)=Wave_U(t-1,n); Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end end %画图 axis([-10 10 -1 5]) plot(x(1,:),Wave_U(1,:),'-r') hold on for i=10:20:200 plot(x(i,:),Wave_U(i,:),'-b') pause(0.3) end case(2) alpha=0.05; DT=0.002;%Δt method=input("select method:Simple explicit Mehods(1)"); switch method case(1) for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)+(alpha*DT/0.05^2)*(Wave_U(t-1,i+1)-2*Wave_U(t-1,i)+Wave_U(t-1,i-1));%wave equation_Euler Explicit Method elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else Wave_U(t,n)=Wave_U(t-1,n); end x(t,i)=x(t-1,i); end end end plot(x(1,:),Wave_U(1,:),'-r') hold on axis([-3 3 -1 2]) for i=10:20:200 plot(x(i,:),Wave_U(i,:),'-b') pause(0.3) end case(3) DT=0.02;%Δt method=input("select method:\nEuler explicit Mehods(1),Upstream Differencing Method(2),Second Order Upwind Method(3),\nLeap Frog(4),Lax-Wendroff(5),MacCormac(6)"); %选择有限差分的方法 switch method case(1)%Euler explicit Mehods for t=2:200 for i=1:n if(i>=2&&i<=n-1) Wave_U(t,i)=Wave_U(t-1,i)-(Wave_U(t-1,i)*DT/0.05)*(Wave_U(t-1,i+1)-Wave_U(t-1,i));%wave equation_Euler Explicit Method elseif(i==1) Wave_U(t,1)=Wave_U(t-1,1); else
评论
    相关推荐
    • matlabcnhelp.rar
      matlab中文帮助很难找的,快速下载
    • MobilePolice.rar
      移动警察,车牌识别,车牌定位系统源代码,已经运用在移动车载稽查系统中。
    • SVM(matlab).rar
      支持向量机(SVM)实现的分类算法源码[matlab]
    • svm.zip
      用MATLAB编写的svm源程序,可以实现支持向量机,用于特征分类或提取
    • Classification-MatLab-Toolbox.rar
      模式识别matlab工具箱,包括SVM,ICA,PCA,NN等等模式识别算法,很有参考价值
    • VC++人脸定位实例.rar
      一个经典的人脸识别算法实例,提供人脸五官定位具体算法及两种实现流程.
    • QPSK_Simulink.rar
      QPSK的Matlab/Simulink的调制解调仿真系统,给出接收信号眼图及系统仿真误码率,包含载波恢复,匹配滤波,定时恢复等重要模块,帮助理解QPSK的系统
    • LPRBPDemo2009KV.rar
      车牌识别,神经网络算法,识别率高达95%,识别时间低于80ms。
    • MODULATION.RAR
      这个源程序代码包提供了通信系统中BPSK,QPSK,OQPSK,MSK,MSK2,GMSK,QAM,QAM16等调制解调方式 用matlab的实现,以及它们在AWGN和Rayleigh信道下的通信系统实现及误码率性能
    • algorithms.rar
      十大算法论文,包括遗传算法,模拟退火,蒙特卡罗法等等,对于初学者很有帮助!!