matlab/matlab-agentic-toolkit / skills-catalog/math-and-optimization/matlab-solve-pde
matlab-solve-pde
VerifiedEnd-to-end finite element analysis in MATLAB PDE Toolbox — geometry creation, model setup, solve, and post-processing in one skill. Use when building geometry from primitives or file import, setting up femodel with BCs/loads/materials, solving thermal/structural/EM problems, and extracting or visualizing results. Covers fegeometry, multicuboid, multicylinder, multisphere, decsg, boolean ops, mesh generation, femodel, all AnalysisTypes (thermalSteady, thermalTransient, structuralStatic, structuralTransient, structuralModal, structuralFrequency, electrostatic, magnetostatic, dcConduction, harmonic EM), materialProperties, faceBC, faceLoad, cellLoad, vertexLoad, solve, interpolation, von Mises stress, principal stress, reaction forces, heat flux, pdeplot3D visualization. Triggers on: PDE Toolbox, finite element, FEA, thermal analysis, structural analysis, electromagnetic analysis, femodel, mesh, boundary conditions, stress, displacement, heat transfer, post-processing.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 25.1 KB |
| manifest.yaml | config | 496 B |
| references/bc-load-reference.md | markdown | 4.9 KB |
| references/boolean-and-cell-ops.md | markdown | 4.5 KB |
| references/damping-reference.md | markdown | 2.1 KB |
| references/decsg-and-2d-geometry.md | markdown | 2.3 KB |
| references/electromagnetic-setup.md | markdown | 4.8 KB |
| references/em-postprocessing.md | markdown | 4.1 KB |
| references/modal-and-reduced-order.md | markdown | 3.0 KB |
| references/nonconstant-parameters.md | markdown | 4.3 KB |
| references/primitives-and-import.md | markdown | 4.8 KB |
| references/time-dependent-loads.md | markdown | 2.7 KB |
| references/visualization-reference.md | markdown | 6.0 KB |
references/visualization-reference.md
View on GitHub# PDE Toolbox Visualization Reference
Always prefer PDE Toolbox-specific plotting options over raw MATLAB graphics.
## Function Selection
| Task | 2-D | 3-D |
|------|-----|-----|
| Geometry with labels | `pdegplot` | `pdegplot` |
| Mesh only | `pdemesh` | `pdemesh` |
| Scalar field (color) | `pdeplot` (XYData) | `pdeplot3D` (ColorMapData) |
| Vector field (quiver) | `pdeplot` (FlowData) | `pdeplot3D` (FlowData) |
| Contour lines | `pdeplot` (Contour) | Not available — use `contourslice` |
| Deformed shape | `pdeplot` (Deformation) | `pdeplot3D` (Deformation) |
| Interactive | `pdeviz` | `pdeviz` |
**Critical:** `pdeplot` is 2-D only. Use `pdeplot3D` for 3-D meshes.
## pdegplot — Geometry
```matlab
pdegplot(gm, FaceLabels="on", FaceAlpha=0.3); % Essential for identifying faces
pdegplot(gm, EdgeLabels="on", VertexLabels="on"); % 2-D
pdegplot(gm, CellLabels="on", FaceAlpha=0.2); % Multi-cell
```
Options: `VertexLabels`, `EdgeLabels`, `FaceLabels`, `CellLabels`, `FaceAlpha`, `FaceColor`, `Lighting`.
## pdeplot3D — 3-D Results
```matlab
pdeplot3D(result.Mesh, ColorMapData=result.Temperature, Mesh="on");
colorbar; title("Temperature");
% Deformed shape (static)
pdeplot3D(result.Mesh, ColorMapData=result.VonMisesStress, ...
Deformation=result.Displacement, DeformationScaleFactor=100);
% Deformed shape (transient — filterByIndex first!)
resultF = filterByIndex(result, numel(result.SolutionTimes));
vm = evaluateVonMisesStress(resultF);
pdeplot3D(resultF.Mesh, ColorMapData=vm, ...
Deformation=resultF.Displacement, DeformationScaleFactor=100);
% Vector field (quiver)
[qx, qy, qz] = evaluateHeatFlux(result);
pdeplot3D(result.Mesh, FlowData=[qx qy qz]);
% Transparent
pdeplot3D(result.Mesh, ColorMapData=result.Temperature, FaceAlpha=0.5);
```
Options: `ColorMapData`, `FlowData`, `Mesh`, `Deformation`, `DeformationScaleFactor`, `FaceAlpha`, `NodeLabels`, `ElementLabels`.
**Not available on pdeplot3D** (use base MATLAB after):
- Colormap → `colormap("hot")`
- Colorbar → `colorbar`
- Color limits → `clim([lo hi])`
- Title → `title("...")`
## pdeplot — 2-D Results
```matlab
% Temperature with contours
pdeplot(result.Mesh, XYData=result.Temperature, Contour="on", Levels=15, Mesh="on");
% Heat flux quiver
[gx, gy, ~] = evaluateTemperatureGradient(result);
pdeplot(result.Mesh, XYData=result.Temperature, FlowData=[-gx -gy]);
% Deformed shape
pdeplot(result.Mesh, XYData=result.VonMisesStress, ...
Deformation=result.Displacement, DeformationScaleFactor=50);
```
Options: `XYData`, `XYStyle`, `ZData`, `FlowData`, `Deformation`, `DeformationScaleFactor`, `Mesh`, `Contour`, `Levels`, `ColorMap`, `ColorBar`.
## pdeviz — Interactive (R2021a+)
```matlab
pdeviz(result.Mesh, result.Temperature, Title="Temperature");
pdeviz(result.Mesh, result.VonMisesStress, ...
DeformationData=result.Displacement, DeformationScaleFactor=200);
```
Use for quick inspection. Use `pdeplot`/`pdeplot3D` for publication figures, quiver, multi-panel.
## FlowData Format
| Function | Shape | Content |
|----------|-------|---------|
| `pdeplot` | N×2 `[Fx Fy]` | 2-D vector field at nodes |
| `pdeplot3D` | N×3 `[Fx Fy Fz]` | 3-D vector field at nodes |
## Partial Mesh Plotting (Subset of Elements)
`pdeplot3D` accepts `(nodes, elements)` instead of a mesh object. Use `findElements` to select a subset — plot full solution on partial mesh to see interior regions (e.g., remove air volume in EM):
```matlab
% Find elements belonging to specific cells (e.g., iron core, skip air)
elemIDs = findElements(result.Mesh, "region", Face=[1 2]); % 2-D
elemIDs = findElements(result.Mesh, "region", Cell=[1 3]); % 3-D
% Plot full solution on subset of mesh — pass ALL node data, subset of elements
nodes = result.Mesh.Nodes;
elements = result.Mesh.Elements(:, elemIDs);
pdeplot3D(nodes, elements, ColorMapData=result.MagneticFluxDensity.Magnitude);
```
Solution data is at nodes (not elements) — pass the full solution vector. Only the selected elements are rendered; unreferenced nodes are simply not drawn. No interpolation needed. Ideal for:
- EM: hiding air volume to see flux density in core/magnets
- Multi-material: isolating one region for inspection
- Interior views without cutting planes
## Cross-Section Visualization (3-D → 2-D slice)
```matlab
[xq, yq] = meshgrid(linspace(xmin, xmax, 50), linspace(ymin, ymax, 50));
zq = 0.005 * ones(size(xq));
queryPts = [xq(:)'; yq(:)'; zq(:)'];
Tq = interpolateTemperature(result, queryPts);
Tgrid = reshape(Tq, size(xq));
contourf(xq, yq, Tgrid, 20); colorbar;
```
## Streamline Visualization (Vector Fields)
No PDE Toolbox streamline option — interpolate to a regular grid and use base MATLAB `streamline`:
```matlab
% Interpolate vector field to regular grid
[xq, yq, zq] = meshgrid(linspace(xmin,xmax,20), ...
linspace(ymin,ymax,20), ...
linspace(zmin,zmax,20));
queryPts = [xq(:)'; yq(:)'; zq(:)'];
Jq = interpolateCurrentDensity(result, queryPts);
Jxg = reshape(Jq.Jx, size(xq));
Jyg = reshape(Jq.Jy, size(yq));
Jzg = reshape(Jq.Jz, size(zq));
% Start points for streamlines
[sx, sy, sz] = meshgrid(xmin, linspace(ymin,ymax,5), linspace(zmin,zmax,5));
streamline(xq,yq,zq, Jxg,Jyg,Jzg, sx,sy,sz);
```
Works with any vector FEStruct result (heat flux, magnetic field, current density). Replace `interpolateCurrentDensity` with the appropriate interpolation function.
## Multi-Panel Layout
```matlab
figure; tiledlayout(1,2);
nexttile; pdeplot3D(result.Mesh, ColorMapData=result.Temperature);
colorbar; title("Temperature");
nexttile; pdeplot3D(result.Mesh, FlowData=[qx qy qz]);
title("Heat flux");
```
## Key Pitfalls
| Temptation | Use Instead |
|------------|-------------|
| `quiver(x,y,u,v)` for flux | `pdeplot(..., FlowData=[Fx Fy])` |
| `trisurf(tri,x,y,T)` | `pdeplot(mesh, XYData=T)` |
| `patch` for deformed shape | `pdeplot3D(..., Deformation=D)` |
| `scatter3(x,y,z,[],T)` | `pdeplot3D(mesh, ColorMapData=T)` |
| `subplot` | `tiledlayout`/`nexttile` |
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 468k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |