偏微分各差分格式MATLAB编程

更新时间:2023-06-08 22:40:25 阅读: 评论:0

(1)迎风格式
function u = peHypbYF(a,dt,n,minx,maxx,M)
format long;
h = (maxx-minx)/(n-1);
if a>0
    for j=1:(n+M)
        u0(j) = IniU(minx+(j-M-1)*h);
    end
el 
    for j=1:(n+M)
        u0(j) = IniU(minx+(j-1)*h);
    end
end 
u1 = u0;
for k=1:M
    if a>0
        for i=(k+1):n+M
            u1(i) = -(dt/h)*a*(u0(i)-u0(i-1))+u0(i);
        end
    el
        for i=1:n+M-k
            u1(i) = -(dt/h)*a*(u0(i+1)-u0(i))+u0(i);
        end
    end
    u0 = u1;
end
x=0.01:0.01:n/100;
u = u1((M+1):(M+n));
plot(x,u,'r');
axis([0 1 -0.5 1.5]);
hold on
y=1.*(x<=0.5)+0.*(x>0.5);
plot(x,y,'g')
title('Ó­·ç¸ñʽ')
format short;
运行结果
>> u=peHypbYF(1,0.005,101,0,1,100)
(2)Lax-Fridrichs格式
function u = LaxFridrichs(a,dt,n,minx,maxx,M)
format long;
h = (maxx-minx)/(n-1);
for j=1:(n+2*M)
        u0(j) = IniU(minx+(j-M-1)*h);
end 简爱第一章读后感
u1 = u0;
工作语言for k=1:M
    for i=k+1:n+2*M-k
销售方案模板
        u1(i) = -(dt/h)*a*(u0(i+1)-u0(i-1))/2+(u0(i+1)+u0(i-1))/2;
    end
    u0 = u1;
end
x=0.01:0.01:n/100;
u = u1((M+1):(M+n));
plot(x,u,'r');
axis([0 1 -0.5 1.5]);
hold on
y=1.*(x<=0.5)+0.*(x>0.5);
plot(x,y,'g')
title('Lax-Fridrichs¸ñʽ')
format short;
运行结果
>> u = LaxFridrichs(1,0.005,101,0,1,100)
(3)Lax-a上面两个点Wendroff格式
function u = LaxWendroff(a,dt,n,minx,maxx,M)
团子头format long;
h = (maxx-minx)/(n-1);
for j=1:(n+2*M)
        u0(j) = IniU(minx+(j-M-1)*h);
end
u1 = u0;
for k=1:M
    for i=k+1:n+2*M-k
        u1(i) = (dt/h)^2*a*a*(u0(i+1)-2*u0(i)+u0(i-1))/2- ...
                  (dt/h)*a*(u0(i+1)-u0(i-1))/2+u0(i);
    end
    u0 = u1;成长感悟
end
x=0.01:0.01:n/100;
门的简笔画u = u1((M+1):(M+n));
原始心管搏动plot(x,u,'r');
axis([0 1 -0.5 1.5]);
hold on
y=1.*(x<=0.5)+0.*(x>0.5);
plot(x,y,'g')
title('Lax-Wendroff¸ñʽ')
format short
运行结果

本文发布于:2023-06-08 22:40:25,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/906165.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:销售   搏动   迎风
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图