How to assign default values to function inputs
Afficher commentaires plus anciens
I have a function with some required inputs,
heatContent = function(swRadiation, lwRadiation)
If the user passes in [] for any of the inputs, I would like to substitute default values (swRadiation=100 or lwRadiation=50). Also if the user only passes in 1 input, I would substitute in lwradiation=50 for the second input. I believe I can use inputparser to do this, but the following gives an error (Undefined function or variable 'lwRadiation'). I could write a long chain of if/elseif statements but suspect there is a more compact way.
p = inputparser;
addOptional(p,'swRadation',50);
addOptional(p,'lwRadiation',100);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Argument Definitions dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!