1、华科电磁场matlab仿真作业电磁场作业 电气1202 XXX U201200000一 作业一1. 程序框图2. 程序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 %初始化
2、电势完毕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) +
3、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);3. 计算机绘图二 作业二1.程序框图2.程序clear;col=101;row=101;A=zeros(row,col);for i=11:101 A(i,11)=100;endfor j=11:101 A(11
4、,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 x0.1 x=0; for i=2:100 for j=2:100 if (i1&i1&jx) 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);
5、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.计算机绘图
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1