General usage of ParseInputs
19 次查看(过去 30 天)
显示 更早的评论
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
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
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
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
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 Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!