Mercurial > hg > octave-max
annotate scripts/image/prism.m @ 11188:4cb1522e4d0f
Use function handle as input to cellfun,
rather than quoted function name or anonymous function wrapper.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 03 Nov 2010 17:20:56 -0700 |
parents | 2b0cc0b6db61 |
children | 466ba499eff5 |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 1999, 2000, 2007, 2009 Kai Habel |
6788 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6788 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6788 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} prism (@var{n}) | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
7017
diff
changeset
|
21 ## Create color colormap. This colormap cycles trough red, orange, yellow, |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
7017
diff
changeset
|
22 ## green, blue and violet. The argument @var{n} should be a scalar. If it |
6788 | 23 ## is omitted, the length of the current colormap or 64 is assumed. |
24 ## @seealso{colormap} | |
25 ## @end deftypefn | |
26 | |
27 ## Author: Kai Habel <kai.habel@gmx.de> | |
28 | |
29 function map = prism (number) | |
30 | |
31 if (nargin == 0) | |
32 number = rows (colormap); | |
33 elseif (nargin == 1) | |
6791 | 34 if (! isscalar (number)) |
6788 | 35 error ("prism: argument must be a scalar"); |
36 endif | |
37 else | |
38 print_usage (); | |
39 endif | |
40 | |
41 p = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1]; | |
42 | |
43 if (rem (number, 6) == 0) | |
44 map = kron(ones (fix (number / 6), 1), p); | |
45 else | |
46 map = [kron(ones (fix (number / 6), 1), p); p(1:rem (number, 6), :)]; | |
47 endif | |
48 | |
49 endfunction | |
9751
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
50 |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
51 %!demo |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
52 %! ## Show the 'prism' colormap as an image |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
53 %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
54 %! axis ([1, 64, 0, 1], "ticy", "xy") |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
55 %! colormap prism |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
9245
diff
changeset
|
56 |