defaults.m

Versione 1.0.0.0 (1,92 KB) da jl
Utility function to simplify setting default values for variables in functions.
308 download
Aggiornato 30 lug 2014

Visualizza la licenza

Syntax:
DEFAULTS('Variable',Value)

Problem:
Usually in a function call:
out = function(Var1, Var2)

if (~exist('Var1','var')
Var1 = 1234;
end
if (~exist('Var2','var')
Var2 = 3456;
end

This gets tedious after a while.

Solution using DEFAULTS
out = function(Var1, Var2)
defaults('Var1',1234,'Var2',3456);

Cita come

jl (2025). defaults.m (https://it.mathworks.com/matlabcentral/fileexchange/47394-defaults-m), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2011a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Argument Definitions in Help Center e MATLAB Answers
Tag Aggiungi tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0