Mercurial > octave
diff scripts/image/image.m @ 10942:48a1812fcc3a
image.m: Matlab compatible axis limits, add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 03 Sep 2010 08:04:10 -0400 |
parents | 947adebb1336 |
children | 18b0af0bbd6b |
line wrap: on
line diff
--- a/scripts/image/image.m Wed Sep 01 20:22:48 2010 -0400 +++ b/scripts/image/image.m Fri Sep 03 08:04:10 2010 -0400 @@ -119,9 +119,12 @@ xdata = [x(1), x(end)]; ydata = [y(1), y(end)]; - xlim = [x(1)-0.5, x(end)+0.5]; - ylim = [y(1)-0.5, y(end)+0.5]; + c = size (img, 2); + xlim = 0.5 * ((x(end) - x(1)) * c / (c - 1) * [-1, 1] + (x(1) + x(end))); + r = size (img, 1); + ylim = 0.5 * ((y(end) - y(1)) * r / (r - 1) * [-1, 1] + (y(1) + y(end))); + ca = gca (); tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, @@ -154,3 +157,11 @@ endif endfunction + +%!demo +%! img = 1 ./ hilb (10); +%! x = 20 * rand (1, 41) - 20; +%! y = -1:1; +%! h = image (x, y, img); +%! set (h, "cdatamapping", "scaled") +