필터 지우기
필터 지우기

How to comment out unused arguments in function header

조회 수: 1 (최근 30일)
Daniel
Daniel 2013년 12월 30일
답변: Jacob Halbrooks 2013년 12월 30일
I want to put arguments I am currently not using in certain function header into comments so that I can call the function without those arguments.
The reason for that, is that at the moment my code is not using those arguments, but I want them there for later, when I can suplly the actual arguments I need there.
Anyone know what I can use there? neither %{ %} nor ... are working for some reason.
Is there something like /* */ from Java?
  댓글 수: 1
John D'Errico
John D'Errico 2013년 12월 30일
I think it is time for you to learn to use one of the MANY ways of doing this without the kludge of comments. MATLAB can handle a variable number of arguments very nicely. Use varargin, or learn how to supply empty arguments as a placeholder, or learn how matlab works it when you simply don't supply values at all for the last few arguments of a function.

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

채택된 답변

Jacob Halbrooks
Jacob Halbrooks 2013년 12월 30일
Consider writing your functions to take parameter/value pairs. By doing this, you could define optional parameters that don't need to be passed in, and the approach provides a clean, extensible interface.
A typical function written this way would take varargin as the function input and then use inputParser to define parameters and process them. For examples, see the doc:
doc inputParser

추가 답변 (0개)

카테고리

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