RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
    • Grammar
    • Declarations
    • Procedures
    • Types, units and expressions
    • Files, modules and imports
    • Studies, analyses and state
    • Outputs, fields and observations
    • Operations and output queries
    • Operation reference
    • RunMat function integration
    • Diagnostics and tooling
    • Geometry features and AP242
    • Geometry, models and assignments
    • Constraints, loads and interfaces
    • Fluid materials
Docs>Physics>Language reference

RunMat function integration

Use a .m function when an input requires bounded computation that does not belong in the declarative language. The import names both the symbol and its file:

import function impactPulse from "./impactPulse.m"

The imported file must define the named function entrypoint. RunMat checks its arguments, result, effects, capabilities, source digest, and executable revision through the ordinary project pipeline. Scripts, ambient workspace reads, unapproved effects, ambiguous definitions, or an incompatible result fail before materialization. Numerical signal generators may suspend only when the compiler proves deterministic data-local work, including cooperative CPU turns or completion of their owned numerical provider operations. Arbitrary asynchronous calls, unknown targets and opaque receiver overrides do not inherit this permission.

Generated signals

model impact_test {
    signal pulse : force over time {
        generated by function.impactPulse {
            arguments {
                peak = 1 kN
                duration = 6 ms
            }
            sample from 0 s to 50 ms at 100 kHz
            interpolation = linear
            extrapolation = reject
            tolerance = 1e-5 N
        }
    }
}

The corresponding impactPulse.m receives the requested sample coordinates as its first argument. Quantity-bearing .fea arguments cross this boundary as canonical SI numeric values: newtons for peak, seconds for duration, and seconds for time. The result must have one value per requested sample:

function force = impactPulse(time, peak, duration)
  arguments
      time (:,1) double
      peak (1,1) double
      duration (1,1) double
  end

  insidePulse = time <= duration;
  phase = min(time ./ duration, 1);
  force = peak .* sin(pi .* phase) .* insidePulse;
end

The signal declaration owns physical quantity, domain, sample range, interpolation, extrapolation, and tolerance. The .m function computes values for admitted samples; it does not mutate the model, select geometry, or run inside a solver kernel.

Sampling is deterministic. RunMat may divide the sample domain into portable chunks and place those chunks locally or on cluster workers. The materialized signal records the function source, arguments, sample contract, result digest, and execution evidence so local and remote paths can be compared exactly.

Explicit physical axes and complex frequency inputs

Use sample_points instead of the uniform time declaration when the requested coordinates are explicit. Every point must have the signal domain's units; points must be finite and strictly increasing, with at least two entries. Frequency points must be nonnegative. Do not combine sample_points with sample from ... in one generator.

import function harmonicDrive from "./harmonicDrive.m"
model vibration_test {
    signal actuator : force over frequency {
        generated by function.harmonicDrive {
            arguments {}
            sample_points = [10 Hz, 17 Hz, 20 Hz]
            precision = complex128
            interpolation = linear
            extrapolation = reject
        }
    }
}

The function receives the frequency coordinates in hertz and returns one complex phasor per coordinate. For example:

function force = harmonicDrive(frequency)
  arguments
      frequency (:,1) double
  end
  force = (1 + 0.4i) * frequency;
end

The numeric argument declaration supplies the static callable contract; an untyped parameter is not automatically assumed to be a numeric sample axis.

precision defaults to real64; declare complex128 to retain complex samples. A complex result cannot silently realize a real-only declaration. Explicit time axes use seconds, for example sample_points = [0 s, 6 ms, 50 ms]. This is the shared generated-signal contract, not a thermal-specific path. Declaring an input does not qualify a solver or execution placement: each consuming formulation still has its own admission and evidence gates. Generated values are materialized before numerical execution, not called from a solver kernel.

Generated spectra

Response spectra and random-excitation spectra use the same import boundary. Their declarations still own frequency or period axes, ordinate quantity, damping, response measure, channels, spectral convention, interpolation, extrapolation, and evidence. A function returns samples; it does not define those FEA semantics implicitly.

Generated geometry

A geometry declaration may materialize a typed function result:

geometry bracket {
    input width : length = 80 mm

    generated by function.makeBracket {
        arguments {
            width = input.width
        }
    }

    region body : solid {
        select output.region.body
        expect exactly_one
    }
}

makeBracket.m returns the typed geometry value expected by that declaration. Geometry operations are the same immutable operations available to ordinary RunMat code; geometry.withRegion gives the returned body the output.region.body name used by the .fea selector:

function part = makeBracket(width)
  arguments
      width (1,1) double
  end

  depth = 0.05;
  height = 0.008;
  holeRadius = 0.005;

  stock = geometry.box(width, depth, height);
  hole = geometry.cylinder(holeRadius, height, [0 0 1], ...
      [width / 2, depth / 2, 0]);
  body = geometry.subtract(stock, hole);

  part = geometry.finish(body);
  part = geometry.withRegion(part, "body", geometry.solid(body));
end

Lengths arrive in meters because length inputs normalize to SI before portable function execution. The function does not read the .fea geometry declaration or invent selector names at runtime; its checked return value explicitly publishes the named region.

The function result must satisfy the declared geometry-output contract. RunMat admits the result through the same canonical geometry validation, persistent-topology, region, meshing, caching, and evidence path as imported or declaratively constructed geometry.

Editor navigation

Go to definition on function.impactPulse opens the imported .m function. Signature help and completion use its checked type. Editing the function invalidates dependent diagnostics and frozen materializations; an old executable revision cannot silently satisfy the new source import.

On this page
  • Generated signals
  • Explicit physical axes and complex frequency inputs
  • Generated spectra
  • Generated geometry
  • Editor navigation