Extendable, but bacward compatible M code.
조회 수: 2 (최근 30일)
이전 댓글 표시
What is the best way of creating M code that can easily be extended, but will remain backward compatible? When creating code, it is beneficial to try to predict future use along with the present use, e.g., which parameters could potentially be of interest to the user.?
It is not possible to predict all parameters that potentially will be changed by future users. How can my M code deal with this problem and still be simple and easy to read?
One solution is to include a struct as parameter to the function. This struct can be extended by new fields, if required.
댓글 수: 0
채택된 답변
Martijn
2011년 2월 25일
Working with structures is indeed an option. Other options include working with VARARGIN and VARARGOUT:
http://www.mathworks.com/help/techdoc/ref/varargin.html http://www.mathworks.com/help/techdoc/ref/varargout.html
Or you could consider working with the inputParser which allows easy implementation of 'parameter', value pairs:
(You could easily add new optional fields later on)
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!