interpolateElectricPotential
Interpolate electric potential in electrostatic or DC conduction result at arbitrary spatial locations
Since R2021a
Syntax
Description
returns the interpolated electric potential values at the points specified in
Vintrp = interpolateElectricPotential(results,querypoints)querypoints.
Examples
Create a square geometry and plot it with the edge labels.
R1 = [3,4,-1,1,1,-1,1,1,-1,-1]'; g = decsg(R1,'R1',('R1')'); pdegplot(g,EdgeLabels="on") xlim([-1.1 1.1]) ylim([-1.1 1.1])

Create an femodel object for electrostatic analysis and include the geometry into the model.
model = femodel(AnalysisType="electrostatic", ... Geometry=g);
Specify the vacuum permittivity in the SI system of units.
model.VacuumPermittivity = 8.8541878128E-12;
Specify the relative permittivity of the material.
model.MaterialProperties = ...
materialProperties(RelativePermittivity=1);Apply the voltage boundary conditions on the edges of the square.
model.EdgeBC([1 3]) = edgeBC(Voltage=0); model.EdgeBC([2 4]) = edgeBC(Voltage=1000);
Specify the charge density for the entire geometry.
model.FaceLoad = faceLoad(ChargeDensity=5E-9);
Generate the mesh.
model = generateMesh(model);
Solve the model and plot the electric potential.
R = solve(model); pdeplot(R.Mesh,XYData=R.ElectricPotential, ... Contour="on") axis equal

Interpolate the resulting electric potential to a grid covering the central portion of the geometry, for x and y from -0.5 to 0.5.
v = linspace(-0.5,0.5,51); [X,Y] = meshgrid(v); Vintrp = interpolateElectricPotential(R,X,Y);
Reshape Vintrp and plot the resulting electric potential.
Vintrp = reshape(Vintrp,size(X));
figure
contourf(X,Y,Vintrp)
colormap(cool)
colorbar
axis equal
Alternatively, you can specify the grid by using a matrix of query points.
querypoints = [X(:),Y(:)]'; Vintrp = interpolateElectricPotential(R,querypoints);
Create an femodel object model for electrostatic analysis and include a geometry of a plate with a hole into the model.
model = femodel(AnalysisType="electrostatic", ... Geometry="PlateHoleSolid.stl");
Plot the geometry.
pdegplot(model.Geometry,FaceLabels="on",FaceAlpha=0.3)
Specify the vacuum permittivity in the SI system of units.
model.VacuumPermittivity = 8.8541878128E-12;
Specify the relative permittivity of the material.
model.MaterialProperties = ...
materialProperties(RelativePermittivity=1);Specify the charge density for the entire geometry.
model.CellLoad = cellLoad(ChargeDensity=5E-9);
Apply the voltage boundary conditions on the side faces and the face bordering the hole.
model.FaceBC(3:6) = faceBC(Voltage=0); model.FaceBC(7) = faceBC(Voltage=1000);
Generate the mesh.
model = generateMesh(model);
Solve the model.
R = solve(model)
R =
ElectrostaticResults with properties:
ElectricPotential: [4747×1 double]
ElectricField: [1×1 FEStruct]
ElectricFluxDensity: [1×1 FEStruct]
Mesh: [1×1 FEMesh]
Plot the electric potential.
pdeplot3D(R.Mesh,ColorMapData=R.ElectricPotential)

Interpolate the resulting electric potential to a grid covering the entire geometry, for x, y, and z.
x = linspace(0,10,11); y = linspace(0,1,5); z = linspace(0,20,11); [X,Y,Z] = meshgrid(x,y,z); Vintrp = interpolateElectricPotential(R,X,Y,Z);
Reshape Vintrp.
Vintrp = reshape(Vintrp,size(X));
Plot the resulting electric potential as a contour slice plot for two values of the y-coordinate.
figure
contourslice(X,Y,Z,Vintrp,[],[0 1],[])
view([10,10,-10])
axis equal
colorbar
Input Arguments
Solution of an electrostatic or DC conduction problem, specified as an ElectrostaticResults or ConductionResults
object. Create results using the solve
function.
x-coordinate query points, specified as a real array.
interpolateElectricPotential evaluates the electric potential at
the 2-D coordinate points [xq(i) yq(i)] or at the 3-D coordinate
points [xq(i) yq(i) zq(i)] for every i. Because of
this, xq, yq, and (if present)
zq must have the same number of entries.
interpolateElectricPotential converts the query points to column
vectors xq(:), yq(:), and (if present)
zq(:). It returns electric potential values as a column vector of
the same size. To ensure that the dimensions of the returned solution are consistent
with the dimensions of the original query points, use reshape. For
example, use Vintrp = reshape(Vintrp,size(xq)).
Example: xq = [0.5 0.5 0.75 0.75]
Data Types: double
y-coordinate query points, specified as a real array.
interpolateElectricPotential evaluates the electric potential at
the 2-D coordinate points [xq(i) yq(i)] or at the 3-D coordinate
points [xq(i) yq(i) zq(i)] for every i. Because of
this, xq, yq, and (if present)
zq must have the same number of entries.
interpolateElectricPotential converts the query points to column
vectors xq(:), yq(:), and (if present)
zq(:). It returns electric potential values as a column vector of
the same size. To ensure that the dimensions of the returned solution are consistent
with the dimensions of the original query points, use reshape. For
example, use Vintrp = reshape(Vintrp,size(yq)).
Example: yq = [1 2 0 0.5]
Data Types: double
z-coordinate query points, specified as a real array.
interpolateElectricPotential evaluates the electric potential at
the 3-D coordinate points [xq(i) yq(i) zq(i)]. Therefore,
xq, yq, and zq must have
the same number of entries.
interpolateElectricPotential converts the query points to column
vectors xq(:), yq(:), and
zq(:). It returns electric potential values as a column vector of the
same size. To ensure that the dimensions of the returned solution are consistent with
the dimensions of the original query points, use reshape. For
example, use Vintrp = reshape(Vintrp,size(zq)).
Example: zq = [1 1 0 1.5]
Data Types: double
Query points, specified as a real matrix with either two rows for 2-D geometry or
three rows for 3-D geometry. interpolateElectricPotential evaluates
the electric potential at the coordinate points querypoints(:,i) for
every i, so each column of querypoints contains
exactly one 2-D or 3-D query point.
Example: For a 2-D geometry, querypoints = [0.5 0.5 0.75 0.75; 1 2 0
0.5]
Data Types: double
Output Arguments
Electric potential at query points, returned as a vector. For query points that are
outside the geometry, Vintrp(i) = NaN.
Version History
Introduced in R2021aThe function now interpolates electric potential in DC conduction results in addition to electrostatic results.
See Also
Objects
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)