How to write functions with input propertys?

조회 수: 3 (최근 30일)
yosey
yosey 2013년 3월 6일
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.
  댓글 수: 1
yosey
yosey 2013년 3월 6일
Thank you all. Parse was the missing node. I'd like to accept all answers, so let me take the first.

댓글을 달려면 로그인하십시오.

채택된 답변

Jason Ross
Jason Ross 2013년 3월 6일

추가 답변 (2개)

Jan
Jan 2013년 3월 6일
편집: Jan 2013년 3월 6일
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.

per isakson
per isakson 2013년 3월 6일
편집: per isakson 2013년 3월 6일
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.

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by