General usage of ParseInputs

8 visualizaciones (últimos 30 días)
Rafael Müller
Rafael Müller el 5 de En. de 2018
Comentada: Walter Roberson el 10 de Feb. de 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 comentario
Adam
Adam el 5 de En. de 2018
Editada: Adam el 5 de En. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Benjamin Kraus
Benjamin Kraus el 5 de En. de 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 comentarios
BA
BA el 10 de Feb. de 2018
Editada: BA el 10 de Feb. de 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
Walter Roberson el 10 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by