在MATLAB中模拟二阶微分方程

时间:2013-12-20 13:53:07

标签: matlab simulation

我需要二阶微分方程的模拟(我的意思是移动图)。我有一个近似的形式,所以没有处理ODE.Just试图找到V(i,j)矩阵与下面的方程式。你可以海V(i,j)与先前的V(i,j)值相关

enter image description here

我需要随时间(t)模拟V(z)。我写了一个代码,但它没有用。我真的需要帮助,谢谢。

这是我的代码:

totalTime = 100; %mSecond
deltaT=.01; %% deltaT
t=0:deltaT:totalTime;
totallength=10;
deltax=0.01;  %% deltaX  = deltaZ actually
x=0:deltax:totallength;

for i=1:numel(t)-1 

    for x = 2:totallength-1

    dV(x) = ((V(x+1)-2*V(x)+V(x-1))/(deltax*deltax));

    end

    for x = 2:totallength-1
        V(x)=dV(x)+deltaT*dV(x);
    end

    V(1) = V(2) ; V(totallength) = V(totallength-1) ;

    plot_Vm(i,1:totallength) = V(1:totallength) ;
    plot(plot_Vm(i, : ), deltax*(0:totallength-1) ) ; % plot Vm vs space
    drawnow ;

end

0 个答案:

没有答案