General usage of ParseInputs

9 ビュー (過去 30 日間)
Rafael Müller
Rafael Müller 2018 年 1 月 5 日
コメント済み: Walter Roberson 2018 年 2 月 10 日
Is there a guideline when I should use ParseInputs for input verification?
On one hand I think it is good to verify that the format of the inputs is according the specifications and on the other hand I am concerned about the performance when creating an object at every function call. Unfortunately, the documentations does not make any recommendations.
Do you have any suggestions?
  1 件のコメント
Adam
Adam 2018 年 1 月 5 日
編集済み: Adam 2018 年 1 月 5 日
I generally use
doc validateattributes
in every public function I write initially. I rarely use a varargin style of argument input so ParseInputs is a bit over the top for my usage, but I have used it sometimes.
When I am writing functions to be called in a massively iterative environment though I generally end up commenting these out. I like to keep them there as comments because they act as excellent documentation as well as (when not commented out) validation, but when called millions of times the overhead can be excessive. Usual overhead for one-call is usually irrelevant for validateattributes. I don't know about ParseInputs though.

サインインしてコメントする。

採用された回答

Benjamin Kraus
Benjamin Kraus 2018 年 1 月 5 日
Are you referring to inputParser? As far as I can tell, there is no MATLAB ParseInputs.
If your concern is performance, my recommendation is to add inputParser to your code, then run the profiler and see whether it is having any significant performance impact. My guess is it won't significantly impact the performance, but the specifics will depend largely on your usage.
  3 件のコメント
BA
BA 2018 年 2 月 10 日
編集済み: BA 2018 年 2 月 10 日
if your´re looking into the Code e.g. of webwrite, there is actually a function-ish "parseInputs()".
edit webwrite
% Parse inputs.
[postData, options] = parseInputs(mfilename, varargin);
When trying to open it via
edit ParseInputs
just a blank (new?) script opens.
My Problem is that coder recognizes this function as not supported but whithout knowing the occasion of this part it´s not easy to tell if it´s neccessary for my Code.
Walter Roberson
Walter Roberson 2018 年 2 月 10 日
>> which -all parseInputs
/Applications/MATLAB_R2017b.app/toolbox/matlab/external/interfaces/webservices/restful/private/parseInputs.m % Private to restful
.. so not something you can call yourself.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by