diff scripts/image/copper.m @ 16466:ac332eb727dd

Simplify calculation of colormaps * scripts/image/copper.m: Replace slower linspace with range operator. * scripts/image/hot.m: Add test for n==2 to allow elimination of subsequent if conditional tests. Replace mod calculation with simpler expression. * scripts/image/rainbow.m: Replace slower linspace with range operator. Align columns of calculation for better code readability.
author Rik <rik@octave.org>
date Sun, 07 Apr 2013 22:24:34 -0700
parents b8a4f313e78e
children d63878346099
line wrap: on
line diff
--- a/scripts/image/copper.m
+++ b/scripts/image/copper.m
@@ -46,7 +46,7 @@
   if (n == 1)
     map = [0, 0, 0];
   elseif (n > 1)
-    x = linspace (0, 1, n)';
+    x = [0:(n-1)]' / (n - 1);
     r = (x < 4/5) .* (5/4 * x) ...
       + (x >= 4/5);
     g = 0.7812 * x;