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
Inventory Manager For Dynamics CRM 4.0
Dockit Migrator for SharePoint 11.8.6905
Australia Post Shipping For Magento 2 1.0.0
StarTrack Shipping For Magento 2 2.0.0
Mydala script 1.3
dotConnect for FreshBooks 1.8
Odoo Kingfisher Theme 1.0
Bitcoin Mining Software - Bitcoin Mining Script 1.0.2
Excel Add-in for Magento 1.7
Excel Add-in for MailChimp 1.7
Devart Excel Add-in for QuickBooks 1.7
Excel Add-in for PostgreSQL 1.7
Devart Excel Add-in for MySQL 1.7
Devart Excel Add-in for NetSuite 1.7
Excel Add-in for Salesforce 1.7
Top Code
ATN Site Builder 3.0
ATN Resume Finder 2.0
PHP Review Script 1.0
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
SecureBridge 8.0
dotConnect for SQLite 5.9
Database Workbench Pro 5.6.10.0
Excel Add-in for PostgreSQL 1.1
EntityDAC 1.6
Excel Add-in for Salesforce 1.1
Excel Add-in for MailChimp 1.1
Aglowsoft SQL Query Tools 8.2
Classified Ad Lister 1.0
Solid File System OS edition 5.1
Top Rated
phpEnter 5.1.
Single Leg MLM 1.2.1
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
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
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