华科电磁场matlab仿真作业
电磁场作业 电气1202 XXX U201200000作业一0V100VΓΓΓΓΓΓ程序框图程序clear;col = 61; %第一行点数row = col; %行数span = 0.3/(col-1); %步长End = ones(1,col)*col; %每一行的终止点Start = ones(1,col); %每一行的起始点A = zeros(row,col); %A矩正存储每点电势for i = (col-1)/3+1:(col-1)*2/3+1 for j = (col-1)/3+1:(col-1)*2/3+1 A(i,j) =100; endend %初始化电势完毕temp = A;for n= 1:500 %迭代次数 for i = 2:row-1 if ( i( (col-1)*2/3+1 ) ) for j = Start(i)+1:End(i)-1 temp(i,j)=(A(i-1,j) +A(i+1,j) +A(i,j-1) +A(i,j+1))/4; end else for j = 2:(col-1)/3 temp(i,j)=(A(i-1,j) +A(i+1,j) +A(i,j-1) +A(i,j+1))/4; end for j = 2*(col-1)/3+2:col-1 temp(i,j)=(A(i-1,j) +A(i+1,j) +A(i,j-1) +A(i,j+1))/4; end end A = temp; endendX = row:-1:1;Y = col:-1:1;[X,Y] = meshgrid(X,Y);figure(1);surf(rot90(A,2));figure(2);contour(rot90(A,2));hold on;[Gx,Gy] = gradient(A,1,1);quiver(Gx,Gy);计算机绘图作业二0V100V1.程序框图2.程序clear;col=101;row=101;A=zeros(row,col);for i=11:101 A(i,11)=100;endfor j=11:101 A(11,j)=100;endfor i=2:10 A(i,col)=10*i-10;endfor j=2:10 A(row,j)=10*j-10;endA1=A;x=1;t=0;while x>0.1 x=0; for i=2:100 for j=2:100 if (i>1&&i<11)||(j>1&&j<11) A1(i,j)=(A(i,j-1)+A(i,j+1)+A(i-1,j)+A(i+1,j))/4; t=abs(A(i,j)-A1(i,j)); if (t>x) x=t; end end end end A=A1;endX = 1:1:row;Y = 1:1:col;[X,Y] = meshgrid(X,Y);figure(1);surf(rot90(A,4));figure(2);contour(rot90(A,4));hold on;[Gx,Gy] = gradient(A,1,1);quiver(Gx,Gy);3.计算机绘图作业三1.程序框图2.程序clear;N = 41; %第一行点数h = 0.2/(N-1); %步长row = (N+1)/2; %行数E = N:-1:N-row+1;%每一行的终止点S = 1:1:N-row+1;%每一行的起始点A = zeros(row,N); %A矩阵存储每点电势A(1,:)=ones(1,E(1))*100; %初始化电势for i = 1:row A(i,S(i)) = 0; A(i,E(i)) = 0;end %初始化电势完毕temp = A;for n= 1:600 %迭代次数 for i = 2:row for j = S(i):E(i) if j ==S(i) || j==E(i) temp(i,j)=0; else temp(i,j)=(3*A(i-1,j) +3*A(i+1,j) +A(i,j-1) +A(i,j+1))/8; end end end A = temp;endX = row:-1:1;Y = N:-1:1;[X,Y] = meshgrid(X,Y);figure(1);surf(rot90(A,2));figure(2);contour(rot90(A,2));3.计算机绘图