matlab 解微分方程出错clear all;clc;load 15.mat;t=celiang(:,1);u1=ce

1个回答

  • clear all;clc;

    load 15.mat;

    t=celiang(:,1);

    u1=celiang(:,2);

    syms u2 i5 ii x u5%定义u1,L1,L2,R1,C1,C3,ii 等

    vU1=celiang(:,2);

    k=length(u1);

    C1=1;

    h=5e-7;

    C3=1;

    R1=1;

    L1=1;

    R2=1;

    L2=1;

    C2=1;

    i1(1)=0;i1(2)=0;%在开始的两个点用的是最简单的使之为零的方法.

    for j=3:k-1

    i1(j)=(vU1(j+1)-vU1(j))*12*C1/(23*h)+16*i1(j-1)/23-5*i1(j-2)/23;

    end

    i1(k)=(vU1(k)-vU1(k-1))*C1/h;

    i1=i1';

    i3=i5+ii-i1;

    fai=x;

    p1 = 1.367e-014;

    p2 =-2.585e-027;

    p3 = -8.37e-011;

    p4 = 3.585e-023;

    p5 = 3.2e-007;

    p6 =-1.298e-019;

    p7 = -0.0002556;

    p8 = 1.143e-016;

    ih= p1*x.^7 + p2*x.^6 + p3*x.^5 + p4*x.^4 + p5*x.^3 +p6*x.^2 + p7*x + p8;

    i7=i3-ih;

    i4=-100*i7;

    u4=u5/100;

    i2=-i4-i5;

    u21=u2-u1;

    %%%%%%%%%%%%%%%%%%%%%

    s=dsolve(diff(u21,t)==i5/C3,diff(i3,t)==(u1-R1*i3-u5)/L1,diff(fai,t)==u5,diff(i4,t)==(u2-u4- R2*i4)/L2);

    u2=s.u2