Clear Filters
Clear Filters

Plotting the Electric Field of a 3D Parallel Plate

20 views (last 30 days)
The code below creates a parallel plate capacitor with a 1000V potential on the top plate, 0V potential on the bottom, and no flow through the wall. Using the PDE solver I've managed to get the nodal solution of the model which represents the electric potential. I wish to know how to properly take and plot the gradient of the field as to produce the electric field at each node. Below is what I have thus far:
model = createpde(3);
importGeometry(model,'Parallel Plate Capacitor.SLDPRT.STL')
pdegplot(model,'FaceLabels','on','FaceAlpha',0.2) % creates simple 3D model
axis equal
'q',[0;0;0],'g',[0;0;0]); % try with no BC
applyBoundaryCondition(model,'dirichlet','Face',3,'u',[1000;1000;1000]) % BC for top plate
applyBoundaryCondition(model,'dirichlet','Face',2,'u',[0;0;0]) % BC for bottom plate
f = [0;0;0]; % source charge (constant)
CA = specifyCoefficients(model,'m',0,...
'f', f);
results = solvepde(model);
v = results.NodalSolution;
pdeplot3D(model,'ColorMapData',v(:,3), 'FaceAlpha', 0.5)
vectorField = gradient(v);
Taking the gradient of the nodalSolutions gives me (hopefully) electric field values in the x,y, and z components of each node. I want to know how I can plot these values onto 3D plot to show the direction and flow of the electric field.
Thank you.

Accepted Answer

Star Strider
Star Strider on 2 Oct 2020
To get the gradient over multiple dimensions, get multiple outputs from it. See specifically Contour Plot of Vector Field for a 2D example. A 3D version would require quiver3. (I don’t have the geometry, so I can’t run your code.)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!