MATLAB 解方程错误
来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/08/29 11:02:59
MATLAB 解方程错误
clear all;clc
vU1=[0;0;0;0;282;336;350;354;354;354;353;351;350];
k=length(vU1);
h=5e-7;
syms vU2
%%%%%%%%%%%
C1=3.6581e-013;
C3=3.6581e-013;
%%%%%%%%%%%%%%%%%%% i1
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';
%%%%%%%%%%%%%%%% i2
i2(1)=0;i2(2)=0;%在开始的两个点用的是最简单的使之为零的方法.
for j=3:k-1
i2(j)=(vU2(j+1)-vU2(j))*12*C3/(23*h)+16*i2(j-1)/23-5*i2(j-2)/23;
end
i2(k)=(vU2(k)-vU2(k-1))*C3/h;
i2=i2';
%%%%%%%%%%%%%%%
eq1=i1+i2;
s=solve(eq1);
disp('vU2='),disp(s.vU2);
![](http://img.wesiedu.com/upload/8/2a/82a882bef0fd400917e54532585d1fb1.jpg)
clear all;clc
vU1=[0;0;0;0;282;336;350;354;354;354;353;351;350];
k=length(vU1);
h=5e-7;
syms vU2
%%%%%%%%%%%
C1=3.6581e-013;
C3=3.6581e-013;
%%%%%%%%%%%%%%%%%%% i1
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';
%%%%%%%%%%%%%%%% i2
i2(1)=0;i2(2)=0;%在开始的两个点用的是最简单的使之为零的方法.
for j=3:k-1
i2(j)=(vU2(j+1)-vU2(j))*12*C3/(23*h)+16*i2(j-1)/23-5*i2(j-2)/23;
end
i2(k)=(vU2(k)-vU2(k-1))*C3/h;
i2=i2';
%%%%%%%%%%%%%%%
eq1=i1+i2;
s=solve(eq1);
disp('vU2='),disp(s.vU2);
![](http://img.wesiedu.com/upload/8/2a/82a882bef0fd400917e54532585d1fb1.jpg)
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
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