statget — Read values from statistics options structures.
statget(options,field) reads one field from a statistics options structure, using case-insensitive unique-prefix matching. Add defaultData to supply a value when the recognized field is empty. The default is an opaque value rather than a numeric conversion: any integer class, shape, and exact payload is returned unchanged when selected.
Syntax
val = statget(options, field)
val = statget(options, field, defaultData)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
options | Any | Yes | — | Statistics options structure. |
field | StringScalar | Yes | — | Option field name or unique leading prefix. |
defaultData | Any | No | — | Value returned when the selected option is empty. |
Returns
| Name | Type | Description |
|---|---|---|
val | Any | Option field value. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:statget:InvalidArgument | Argument grammar does not match statget forms. | statget: invalid argument |
RunMat:statget:InvalidOption | The options argument is not a struct or the field argument is not text. | statget: invalid option |
How statget works
optionsmust be a struct, typically created bystatset.fieldis matched case-insensitively and can be a unique leading prefix of a known statistics option field.- If the requested field is recognized but empty,
statgetreturns the supplied default value when present, otherwise it returns the empty value. - If the requested field is not recognized or is ambiguous, RunMat returns an empty numeric value for compatibility with loose MATLAB option probing.
defaultDataaccepts any data type. Integer defaults keep their class, shape, and exact values.
Examples
Read an explicit option
opts = statset('TolX', 1e-8);
tol = statget(opts, 'TolX')Expected output:
`tol` is `1e-8`.Use a default for an empty option
opts = statset('MaxIter', 100);
tol = statget(opts, 'TolFun', 1e-6)Expected output:
`tol` is `1e-6` because `TolFun` is empty.Use a unique prefix
opts = statset('MaxIter', 100);
iter = statget(opts, 'MaxI')Expected output:
`iter` is `100`.Using statget with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how statget changes the result.
Run a small statget example, explain the result, then change one input and compare the output.
Related Stats functions
Options
Ml
bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne
Summary
binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv
Random
binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd
Hist
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how statget is executed, line by line, in Rust.
- View the source for statget in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.