main - clear all, clc, close %Carlos Moran % PS: 0429409...

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

View Full Document Right Arrow Icon
clear all, clc, close %Carlos Moran % PS: 0429409 %ECE 2317 Applied Electricity and Magnetism %Project: Solution of Laplace's Equation by Finite Differences %Ji Chen format short disp('------Task 1-------------------------------------------------------') %Task creates the table of the volts on the anodes. itermax=1000; N=1; % This variable will be the final tables for the values of N=1,2,4,8. %Any variable with 'f' at the end will be used for the task 5. va=0; vb=0; vc=0; vd=0; vf=0; while N<=32; % These variables are used to dimensions given on the sheet. Nx=N*12; Ny=N*5; Nleft=N*4; Nright=N*4; Nheight=N; % These variable are for the initinal volts. vo=zeros(Nx+1,Ny+1); vP=zeros(Nx+1,Ny+1); for iter=1:itermax iter; for j=2:Ny; for i=2:Nx; %This part of the loop is taking the average of the 4 points. vp(i,j)=.25*(vo(i+1,j)+vo(i-1,j)+vo(i,j-1)+vo(i,j+1)); end end % Here I'm creating the boundary of the matrix for js=(N+1):(N+1) for is=(Nleft+1):(Nleft+Nright+1) vp(is,js)=1; end end for is=1:Nx+1 vp(is,1)=0; vp(is,Ny+1)=0; end for js=1:Ny+1; vp(1,js)=0; vp(Nx+1,js)=0; end vo=vp; end % Here I'm creating the condition for the desired values of N. % Note tahn I'm transposing the tables for future use. if N==1 va=vo'; na=N; end if N==2 vb=vo'; nb=N; end if N==4; vc=vo';
Background image of page 1

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

View Full DocumentRight Arrow Icon
nc=N; end if N==8; vd=vo'; nd=N; end if N==32; vf=vo'; nf=N; end N=N*2; end disp(['This is value of the volts on the row when n= ', num2str(na)]) disp(va(na+1,:)') disp(['This is value of the volts on the row when n= ', num2str(nb)]) disp(vb(nb+1,:)') disp(['This is value of the volts on the row when n= ', num2str(nc)]) disp(vc(nc+1,:)') disp(['This is value of the volts on the row when n= ', num2str(nd)]) disp(vd(nd+1,:)') disp('-----Task 2--------------------------------------------------------') % Task 2 creates the figure when N=8; %All the graphs are in matlab. You don't have to go excel to see them. disp('Refer to figure 1 for the contour graph.')
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2011 for the course ECE 2317 taught by Professor Staff during the Fall '08 term at University of Houston.

Page1 / 5

main - clear all, clc, close %Carlos Moran % PS: 0429409...

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

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