What is the computational cost of an nargin check?

2 views (last 30 days)
I have a program that invokes a function a lot of times in a for loop. In that function I have to check the number of input arguments with an if statement. Does this remarkably influences the run-time? That specific function (which is invoked in the for loop) is a general purpose function so input check is needed.
Thank you, Zoli

Accepted Answer

Stephen23
Stephen23 on 6 Sep 2014
Measure it: use either the profiler, or tic/toc . Make the loop do enough iterations to really create measurable times, and see what including/removing nargin does to the runing time.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!