# HG changeset patch # User Ben Abbott # Date 1283515450 14400 # Node ID 48a1812fcc3a433a1b588c2bc61f232fc507b8d1 # Parent 97294dd3ccd43881733e03347c24d4213fc5a859 image.m: Matlab compatible axis limits, add demo. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-09-03 Ben Abbott + + * image/image.m: Matlab compatible axis limits, add demo. + 2010-09-01 Jaroslav Hajek * io/dlmwrite.m: Don't fclose if file ID is supplied. diff --git a/scripts/image/image.m b/scripts/image/image.m --- 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") +