%Mason Averill %Spring 2019, PHYS 312 %Computational Project, flux through a cube with a point charge %anywhere inside of it %Note, this program is very similar to revA, the x,y,and z values %for R are just adjusted to be inclusive of one entire face of the cube %then the program iterates the same operation for each face of the cube, %then adds the flux through each surface for a final result. %I wouldn't go past more than about 150 partitions, even at 100 %paritions the error is typically less than .01% coulombConst=8.9875517873681764*10^9;%approximate value of k epsilon0=8.85418781762039*10^-12;%approximate value of epsilon zero qEnclosed=1*10^-6;%the value of the point charge enclosed, in coulombs L=50;%length of one side of cube in meters numberOfPartitions=100;%number of partitions to split each face of the cube into, in each %direction. In this case, setting this value at 10 %would result in 100 small areas per face of the %cube, so 600 in total. chargeLocation=[ (4/10)*L (-3/10)*L (2.5/10)*L];%note, the furthest you can place the %charge in any direction is %L/2, since the cube is %centered at the origin. %Else the charge is outside if(abs(chargeLocation(1,1))