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/time-dependent-loads.md
View on GitHub# Time-Dependent Loads and NaN Convention
## How the NaN Probe Works
1. Solver calls function with `state.time = NaN`
2. If function returns `NaN` → coefficient is time-dependent (re-evaluated every step)
3. If function returns numeric → treated as constant for entire simulation
## When You Need Explicit isnan Check
Any function with **conditional logic** (if/else, piecewise):
```matlab
function F = pulseForce(t)
if isnan(t)
F = NaN;
return
end
if t <= 0.005
F = -5000 * sin(pi * t / 0.005);
else
F = 0;
end
end
```
Without check: `NaN <= 0.005` → false → returns 0 → solver uses constant 0 forever.
```matlab
function h = rampConvection(t)
if isnan(t)
h = NaN;
elseif t < 5
h = 10 + 18*t;
else
h = 100;
end
end
```
## When NaN Propagates Automatically
**Pure arithmetic** (no conditionals):
```matlab
heat = @(location, state) 100 * sin(2*pi*state.time) * ones(1, numel(location.x));
flux = @(location, state) state.time * 500 * ones(1, numel(location.x));
```
**Interpolation objects** (`griddedInterpolant` with `'none'` extrapolation):
```matlab
heatInterp = griddedInterpolant(tData, qData, 'linear', 'none');
heatFcn = @(location, state) heatInterp(state.time) * ones(1, numel(location.x));
```
## Vectorization Requirement
Load functions must return **1×N row vector** (N = number of evaluation points):
```matlab
% WRONG: scalar
heat = @(location, state) 500;
% CORRECT: 1×N
heat = @(location, state) 500 * ones(1, numel(location.x));
% CORRECT: spatially varying (location fields are already 1×N)
heat = @(location, state) 500 * location.y / maxY;
```
## Full Pattern (conditional + vectorized)
```matlab
function q = timeVaryingHeat(location, state)
nPts = numel(location.x);
t = state.time;
if isnan(t)
q = NaN(1, nPts);
elseif t < 2
q = 1000 * t/2 * ones(1, nPts);
else
q = 1000 * ones(1, nPts);
end
end
```
## Applies to ALL Time-Dependent Quantities
- `faceLoad(Heat=@fcn)` — thermal heat flux
- `faceLoad(ConvectionCoefficient=@fcn)` — time-varying convection
- `vertexLoad(Force=@fcn)` — structural concentrated force
- `faceLoad(Pressure=@fcn)` — structural pressure
- `faceLoad(SurfaceTraction=@fcn)` — structural traction
- `cellLoad(Heat=@fcn)` — volumetric heat generation
- Any other function-handle coefficient in the femodel workflow
## Debugging Symptom
If transient results show:
- Zero displacement/temperature change despite applied loads
- Constant results that don't vary with time
- Results that look like steady-state
→ Check conditional load functions for missing `isnan` handling.
----
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: 471k | 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: 322k | 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: 322k | 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: 322k | Updated | Claude CodeCodex | Verified | Install |