chen - v2(is,ny+1)=0; end for js=1:ny+1 v2(1,js)=0;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
clear all,clc n=input('the number of segment under h-->'); nx=n*12; ny=n*5; nleft=4*n; nwidth=4*n; nheight=n; v1=zeros(nx+1,ny+1); v2=zeros(nx+1,ny+1); itermax=1000; for iter=1:itermax; iter; for j=2:ny for i=2:nx v2(i,j)=0.25*(v1(i+1,j)+v1(i-1,j)+v1(i,j-1)+v1(i,j+1)); end end %boundary condition for js=(n+1):(n+1) for is=(nleft+1):(nleft+nwidth+1) v2(is,js)=1; end end % boundary top and bottom for is=1:nx+1 v2(is,1)=0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: v2(is,ny+1)=0; end for js=1:ny+1 v2(1,js)=0; v2(nx+1,js)=0; end v1=v2; end subplot(221);imagesc(v1');axis equal;colorbar %electric field [fx fy]=gradient(v1'); subplot(222);imagesc(fx);axis equal;colorbar subplot(223);imagesc(fy);axis equal;colorbar delta=1/(4*n); sta=0; sta=0; for i=nleft+1:(nleft+nwidth+1) swa=(v1(i,2)-v1(i,3))/delta; sta(i)=swa; end disp(sta)...
View Full Document

Page1 / 2

chen - v2(is,ny+1)=0; end for js=1:ny+1 v2(1,js)=0;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online