Mercurial > hg > octave-terminal
changeset 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 | 97294dd3ccd4 |
children | 90450db218e4 |
files | scripts/ChangeLog scripts/image/image.m |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-09-03 Ben Abbott <bpabbott@mac.com> + + * image/image.m: Matlab compatible axis limits, add demo. + 2010-09-01 Jaroslav Hajek <highegg@gmail.com> * io/dlmwrite.m: Don't fclose if file ID is supplied.
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -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") +