How to write functions with input propertys?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
MATLAB has a lot of functions with input propertys. As an example:
plot(...,'PropertyName',PropertyValue,...)
When my own functions are getting lots of input arguments its often looking like this:
myfcn(X,Y,[],[],[],[],[],[],[],[],[],[],[],b)
For this situations I want to learn how to write functions with input propertys.
Is it explained somewhere in the matlab help? Is that object oriented programming? Is there a function that I can open and learn from? (I found only 'Built-in functions') Which keywords can I use for google etc.
Risposta accettata
Più risposte (2)
Jan
il 6 Mar 2013
Modificato: Jan
il 6 Mar 2013
This is a good point to start from: http://blogs.mathworks.com/community/2012/02/13/parsing-inputs/ . You can find further links by searching for "Matlab parse inputs". The method to use a name of a property and the its value is called "property value pair".
Object oriented programming is another topic.
0 Commenti
per isakson
il 6 Mar 2013
Modificato: per isakson
il 6 Mar 2013
Here are some links to the File Exchange. The first, parse_pv_pairs, is especially well documented.
And search "Parse Function Inputs" and "inputParser" in the on-line help.
0 Commenti
Vedere anche
Categorie
Scopri di più su Argument Definitions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!