General usage of ParseInputs
6 views (last 30 days)
Show older comments
Rafael Müller
on 5 Jan 2018
Commented: Walter Roberson
on 10 Feb 2018
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 Comment
Adam
on 5 Jan 2018
Edited: Adam
on 5 Jan 2018
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.
Accepted Answer
Benjamin Kraus
on 5 Jan 2018
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 Comments
BA
on 10 Feb 2018
Edited: BA
on 10 Feb 2018
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
on 10 Feb 2018
>> 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.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!