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/nonconstant-parameters.md
View on GitHub# Nonconstant (Function) Parameters — Full Reference
## Function Signatures
Most parameters: `@(location, state) ...`
Initial conditions only: `@(location) ...`
## location Structure
| Field | Available for |
|-------|--------------|
| `.x`, `.y`, `.z` | All parameters |
| `.nx`, `.ny`, `.nz` | Boundary conditions and boundary loads only |
## state Structure — Fields by Analysis Type
### Structural
| Parameter category | state fields received |
|-------------------|---------------------|
| Material properties (E, ν, G, ρ) | none — spatial only |
| BCs and loads (pressure, traction, force, spring, displacement) | `.time` or `.frequency` |
| Initial conditions (displacement, velocity) | one-arg function, no state |
### Thermal
| Parameter category | state fields received |
|-------------------|---------------------|
| Material properties (k, ρ, cp) + internal heat source | `.u`, `.ux`, `.uy`, `.uz`, `.time` |
| Boundary conditions (temperature, heat flux, convection) | `.u`, `.time` |
| Initial temperature | one-arg function, no state |
### Electromagnetic
| Parameter category | state fields received |
|-------------------|---------------------|
| Material properties — electrostatic/dcConduction | none — spatial only |
| Material properties — harmonic EM | `.frequency` |
| Material properties — nonlinear magnetostatic | `.NormFluxDensity`, `.u`, `.ux`, `.uy`, `.uz` |
| Sources (charge density, current density, magnetization) | same as material for that type |
| BCs (voltage, magnetic potential) | none |
| Initial conditions | one-arg (magnetostatic may receive `.NormFluxDensity`) |
## NaN Convention
The solver detects time/state dependence by calling the function with `NaN` in state fields. The function **must** return a `NaN` matrix of the correct output size. If it errors on NaN input, the solver cannot classify the dependence.
Pattern:
```matlab
myLoad = @(location, state) applyLoad(location, state);
function val = applyLoad(location, state)
Np = numel(location.x);
if isnan(state.time)
val = NaN(1, Np);
return
end
val = 1e5*sin(2*pi*100*state.time)*ones(1, Np);
end
```
## Output Size Rules
### Scalar parameters (pressure, temperature, density, etc.)
Return **1×Np** row vector where `Np = numel(location.x)`.
### Vector parameters
| Parameter | 2-D output | 3-D output |
|-----------|-----------|-----------|
| Surface traction | 2×Np | 3×Np |
| Force | 2×Np | 3×Np |
| Spring stiffness | 2×Np | 3×Np |
| Displacement (enforced) | 2×Np | 3×Np |
| Initial displacement/velocity | 2×Np | 3×Np |
| Current density (magnetostatic/harmonic 3-D) | 3×Np | 3×Np |
| Current density (magnetostatic/magneticHarmonic 2-D) | 1×Np | — |
| Current density (electricHarmonic 2-D) | 2×Np | — |
| Magnetization | 2×Np | 3×Np |
### Material vectors (orthotropic structural)
YoungsModulus, PoissonsRatio, ShearModulus: always **3×Np** (both 2-D and 3-D).
### Thermal conductivity (anisotropic)
Rows depend on dimension and form:
- 1 row: isotropic
- Ndim rows: diagonal anisotropy
- Ndim*(Ndim+1)/2 rows: symmetric tensor (upper triangle, column-major)
- Ndim² rows: full tensor
Where Ndim = 2 (2-D) or 3 (3-D). Columns = Np.
## Passing Additional Arguments
Use closures to supply extra data:
```matlab
amplitude = 1e5;
freq = 100;
myPressure = @(location, state) amplitude*sin(2*pi*freq*state.time)*ones(1, numel(location.x));
model.FaceLoad(2) = faceLoad(Pressure=myPressure);
```
Or wrap in a helper:
```matlab
model.FaceLoad(2) = faceLoad(Pressure=@(loc,s) myPressureFcn(loc, s, amplitude, freq));
```
## Summary Table: What Can Be a Function
| Category | Parameters | Depends on |
|----------|-----------|------------|
| Structural materials | E, ν, G, ρ | Space only |
| Structural BCs/loads | Pressure, Traction, Force, Spring, Displacement | Space + time/frequency |
| Thermal materials | k, ρ, cp, HeatSource | Space + temperature + time |
| Thermal BCs | Temperature, HeatFlux, Convection | Space + temperature + time |
| EM materials (static) | εr, μr, σ | Space only |
| EM materials (harmonic) | εr, μr, σ | Space + frequency |
| EM materials (nonlinear) | μr | Space + NormFluxDensity + u |
| EM sources | ChargeDensity, CurrentDensity, Magnetization | Same as material |
----
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 |