User Tools

Site Tools


gibson:teaching:fall-2013:math445:lecture5functions

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

The functions we wrote in class are provided below. Each has a description of what we're illustrating, the filename, and then the file contents. You can cut & paste as needed. An example of an if-else statement. isOdd.m <code> function r = isOdd(n) % return 1 if n is odd, 0 if n is even if 2*floor(n/2) ~= n % this will test if n is not even r = 0; else r = 1; end </code> A simpler example of an if-else statement isTwo.m <code> function r = isTwo(n); % return 1 (true) if n is two, % 0 (false) if n is not two % simple example of an if statment if n == 2 r = 1; % true, n is two else r = 0; % false, n is not two end end </code>

gibson/teaching/fall-2013/math445/lecture5functions.1378842898.txt.gz · Last modified: 2013/09/10 12:54 by gibson