2.83333

2.8 | 6 ratings Rate this file 4 Downloads (last 30 days) File Size: 113 Bytes File ID: #9325

iif.m

by Christopher Granade

 

09 Dec 2005 (Updated 12 Dec 2005)

Emulates the ?: functionality of C and C++.

| Watch this File

File Information
Description

Evaluates a condition and returns one of two parameters based on the result.

Usage:
% iif(cond, t, f)
% Returns t if cond == true, and f otherwise.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
12 Dec 2005 John D'Errico

Its nice if you prefer a functional if statement as this is.

My only wish is that the author had included a few lines
of commented help in the code. If this had been done,
then typing "help iif" at the command line would give you
that help. Its very useful for some day in the future when
you want to use this function and can't remember what
the arguments mean.

13 Dec 2005 Matlab User

I think this type of submission should be discouraged.

15 Dec 2005 Michael Robbins

Simple, but not useless I guess.

16 Dec 2005 Mike Zander

One line functions aren't much use, especially when the required syntax is soooo easy!

12 Jan 2006 Duane Hanselman

Help text is required for even simple functions.

28 Mar 2006 Yuri Gribov

Useful.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
iif Christopher Granade 22 Oct 2008 08:09:39
emulate Christopher Granade 22 Oct 2008 08:09:39
parameters Christopher Granade 22 Oct 2008 08:09:39
utilities Christopher Granade 22 Oct 2008 08:09:39
result Christopher Granade 22 Oct 2008 08:09:39
iif Christopher Galvan 17 Mar 2009 09:36:47

Contact us at files@mathworks.com