% nonlinear.m contrasts the image of the unit square under linear and nonlinear transformations clf; x=ones(101,11)*diag(0:0.1:1); % x coordinates for grid y=diag(0:0.01:1)*ones(101,11); % y coordinates for grid s=y; t=x; subplot(2,2,1) plot(x,y,'k-'); hold on plot(s,t,'k:') grid on axis([0 1.5 0 1.5]) title('Grid on the unit square') subplot(2,2,2) a = (2*x + y)/3; b = (x + 3*y)/3; plot(a,b,'k-'); hold on c = (2*s + t)/3; d = (s+3*t)/3; plot(c,d,'k:'); grid on axis([0 1.5 0 1.5]) title('Image under a linear transformation') subplot(2,2,3) plot(x,y,'k-'); hold on plot(s,t,'k:') axis([0 1.5 0 1.5]) grid on title('Grid on the unit square') subplot(2,2,4) p = pi/2; a = x .* cos(p*y); b = x .* sin(p*y); plot(a,b,'k-'); hold on c = s .* cos(p*t); d = s .* sin(p*t); plot(c,d,'k:'); axis([0 1.5 0 1.5]) grid on title('Image under a nonlinear transformation')