{"id":2088,"date":"2008-01-08T13:47:51","date_gmt":"2008-01-08T18:47:51","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/01\/08\/advanced-matlab-varargin-and-nargin-variable-inputs-to-a-function\/"},"modified":"2016-05-18T10:59:31","modified_gmt":"2016-05-18T14:59:31","slug":"advanced-matlab-varargin-and-nargin-variable-inputs-to-a-function","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/01\/08\/advanced-matlab-varargin-and-nargin-variable-inputs-to-a-function\/","title":{"rendered":"Advanced MATLAB: Varargin and Nargin- variable inputs to a function"},"content":{"rendered":"<p>Most MATLAB functions are overloaded. That means that there are several ways to call them and that MATLAB will &#8220;Do The Right Thing&#8221; based on the number and types of inputs. As a simple example you can call SUM<\/p>\n<p><code>sum(M) %this will sum along the columns<br \/>\nsum(M,2) %this will sum along the rows<\/code><\/p>\n<p>This video shows how you can implement the same behavior based on using<\/p>\n<p><strong>VARARGIN<\/strong>: <strong>VAR<\/strong>iable <strong>ARG<\/strong>uments <strong>IN<\/strong><br \/>\n<strong>NARGIN<\/strong>: <strong>N<\/strong>umber <strong>ARG<\/strong>uments <strong>IN<\/strong><\/p>\n<p><embed src=\"https:\/\/blogs.mathworks.com\/images\/pick\/\/FlashVideos\/FlowPlayer.swf?config=%7Bembedded%3Atrue%2CplayList%3A%5B%7BsuggestedClipsInfoUrl%3A%2765%20see%20also%2Etxt%27%2Curl%3A%2765%20Advanced%20Varargin%2Eflv%27%7D%5D%2CbaseURL%3A%27http%3A%2F%2Fblogs%2Emathworks%2Ecom%2Fimages%2Fpick%2FFlashVideos%2F%27%2CsplashImageFile%3A%2765%20Advanced%20Varargin%2Ejpg%27%2Cloop%3Afalse%2CinitialScale%3A%27fit%27%2CshowFullScreenButton%3Afalse%2CautoBuffering%3Afalse%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%5D%2CautoPlay%3Afalse%7D\" type=\"application\/x-shockwave-flash\" width=\"500\" height=\"400\"><\/embed><\/p>\n<p>Other videos have been gathered here:<br \/>\n<a href=\"https:\/\/blogs.mathworks.com\/pick\/category\/video\/\">https:\/\/blogs.mathworks.com\/pick\/category\/video\/<\/a><\/p>\n<p>Other Advanced MATLAB posts have been gathered here:<br \/>\n<a href=\"https:\/\/blogs.mathworks.com\/pick\/category\/advanced-matlab\/\">https:\/\/blogs.mathworks.com\/pick\/category\/advanced-matlab\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most MATLAB functions are overloaded. That means that there are several ways to call them and that MATLAB will &#8220;Do The Right Thing&#8221; based on the number and types of inputs. As a simple&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/01\/08\/advanced-matlab-varargin-and-nargin-variable-inputs-to-a-function\/\">read more >><\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,8,2],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2088"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2088"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2088\/revisions"}],"predecessor-version":[{"id":7296,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2088\/revisions\/7296"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}