Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
GetOrgChart 2.5.3
AnyGantt JS Gantt Charts 8.6.0
AnyChart JS Charts and Dashboards 8.6.0
Multi Vendor Ecommerce Script & Apps 4.0
Magento 2 Inventory Management Extension 1.0
Yipit Clone Script - Daily Deals Software 1.0.2
Devart Excel Add-in for Oracle 1.7
Devart Excel Add-in for Freshdesk 1.7
Devart Excel Add-in for G Suite 1.7
C# QR Code Generator 4.0.2.2
Salesforce WordPress Customer Portal 3.2.0
Single Leg MLM 1.2.1
OzGIS 14.6
Quick Maps For Dynamics CRM 3.1
Job Board Software 4.2
Top Code
MCU 8051 IDE 1.4.7
School Management Script 1.0.4
shopping mall management system 1.0
WinPoker 2.02
SynaSer Serial Port Library 5.0
MLM Software 1.0.2
Planyo online reservation system module 6.x-1.8
SuperGeek Free Document OCR 2.5.6
sipmethod 1.0
School Management CRM 1
STDF file reader 1.0
Farnsworth 1.0
WebKit2.NET 0.10
Simple IP Calculator sub/sup networking 0.0.4
Beremiz 1.0
Top Rated
VisualNEO Web 2018.12.15
Paste phpSoftPro 1.4.1
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
PHP GZ Blog Script 1.1
ATN Jobs Software 4.0
Set default values 1.0
File ID: 85082






Set default values 1.0
Download Set default values 1.0http://www.mathworks.comReport Error Link
License: Shareware
File Size: 10.0 KB
Downloads: 1
Submit Rating:
Set default values 1.0 Description
Description: In order to set default values for variables, I find the start of my functions littered with

if nargin < 1 || isempty(x)
x = 1;
end

if nargin < 2 || isempty(y)
y = 3;
end
etc.

This is pretty ugly, so I've created a wrapper to prettify it. Honestly, it's so simple that I nearly didn't upload this, but it does make your functions cleaner. Now the above is transformed to

SetDefaultValue(1, 'x', 1);
SetDefaultValue(2, 'y', 3);

Note that there are other ways to set defaults. See
http://blogs.mathworks.com/loren/2009/05/0...ction-defaults/

License: Shareware

Related: Upload, Cleaner, Simple, transformed, defaults

O/S:BSD, Linux, Solaris, Mac OS X

File Size: 10.0 KB

Downloads: 1



More Similar Code

If each class's __init__ is used to set default values, it requires that one use super() or explicit parentclass.__init__() calls . Such ugly boilerplate can be avoided with this recipe.



Set nominal values for/group a dataset by specifying a fraction which determines how far away from the original value a nominal value can be.
Ex: A set of velocity data:
v = [0 9.03, 0.1, 5.2, 0.101, 0.095, 5.01,0, 9, 4.9, 9.2, 8.9,...



Setting Default Value in a Drop Down list for a Datagrid is an article that demonstrates how to set default values for the dropdownlist box that has been integrated with the datagrid control. In this article the author explains it clearly with an...



process_varargin is a simple script that allows the user to create a set of default values for attributes in a script then using varargin override those values.



This recipe applies the "once and only once" principle to function default values. Often two or more callables specify the same default values for one or more arguments. This is especially typical when overriding a method. Using the...



Appreciable errors in MSIS00 modeled temperatures can occur for altitudes above 75 km if solar flux and magnetic indices deviate significantly from their default values. This routine automatically downloads needed solar flux and magnetic indices...



Computes the gini coefficient when given a set of values and population weights.

Short on documentation and checks.



Python default values for keyword arguments are evaluated only once and not on every function call. For example following function will not work as user may expect:

def printNow(l=[], now=datetime.now()):
l.append(len(l))



A generator for cycling over a set of values. This recipe shows a generator-based approach for creating repeating alternators as well as several other approaches.



Function to represent 2D or 3D objects filled with the appropriate colormap according to an additionally provided set of values.
Fill the lack of MatLab functions to provide contour plots of 2D and 3D shaped objects.

Inputs: figure...

User Review for Set default values
- required fields
     

Please enter text on the image