% define the matrix A >> A = [.5,0; 0, 2] A = 0.5000 0 0 2.0000 % define a ball in L2 >> [x] = L2_ball(.5); >> size(x) ans = 2 501 % define the matrix A acting on each point in the ball >> for i=1:501, y(:,i) = A*x(:,i); end >> subplot(2,2,1) % plot the ball >> plot(x(1,:),x(2,:)) >> hold on >> subplot(2,2,2) % plot the matrix A acting on the ball >> plot(y(1,:),y(2,:)) >> hold on % repeat >> [x] = L2_ball(1); >> subplot(2,2,1) >> plot(x(1,:),x(2,:),'--') >> for i=1:501, y(:,i) = A*x(:,i); end >> subplot(2,2,2) >> plot(y(1,:),y(2,:),'--') % repeat >> [x] = L2_ball(1.5); >> for i=1:501, y(:,i) = A*x(:,i); end >> subplot(2,2,1) >> plot(x(1,:),x(2,:),'-.') >> subplot(2,2,2) >> plot(y(1,:),y(2,:),'-.') >> axis([-3.2,3.2,-3.2,3.2]) % repeat with balls in L_inf >> [x] = Linf_ball(.5); >> size(x) ans = 2 401 >> subplot(2,2,3) >> plot(x(1,:),x(2,:),'-') >> hold on >> for i=1:401, y(:,i) = A*x(:,i); end >> subplot(2,2,4) >> plot(y(1,:),y(2,:),'-') >> hold on % repeat >> [x] = Linf_ball(1); >> for i=1:401, y(:,i) = A*x(:,i); end >> subplot(2,2,3) >> hold on >> plot(x(1,:),x(2,:),'--') >> subplot(2,2,4) >> plot(y(1,:),y(2,:),'--') % repeat >> [x] = Linf_ball(1.5); >> for i=1:401, y(:,i) = A*x(:,i); end >> subplot(2,2,3) >> plot(x(1,:),x(2,:),'-.') >> subplot(2,2,4) >> plot(y(1,:),y(2,:),'-.') >> axis([-3.2,3.2,-3.2,3.2]) >> title('A applied to balls in L_{inf}') % put titles on >> subplot(2,2,3) >> title('Balls in L_{inf}') >> subplot(2,2,2) >> title('A applied to balls in L_{2}') >> subplot(2,2,1) >> title('Balls in L_{2}') % print the figure >> print -dps fig1.ps % define a new matrix, and repeat the above >> A = rand(2,2) A = 0.9501 0.6068 0.2311 0.4860 >> eig(A) ans = 1.1586 0.2775 >> figure(2) >> [x] = L2_ball(.5); >> for i=1:501, y(:,i) = A*x(:,i); end >> subplot(2,2,1) >> plot(x(1,:),x(2,:),'-') >> hold on >> subplot(2,2,2) >> plot(y(1,:),y(2,:),'-') >> hold on >> subplot(2,2,1) >> [x] = L2_ball(1); >> for i=1:501, y(:,i) = A*x(:,i); end >> plot(x(1,:),x(2,:),'--') >> subplot(2,2,2) >> plot(y(1,:),y(2,:),'--') >> subplot(2,2,1) >> [x] = L2_ball(1.5); >> for i=1:501, y(:,i) = A*x(:,i); end >> plot(x(1,:),x(2,:),'-.') >> subplot(2,2,2) >> plot(y(1,:),y(2,:),'-.') >> title('A applied to balls in L_{2}') >> subplot(2,2,1) >> title('Balls in L_{2}') >> subplot(2,2,3) >> clear x y >> [x] = Linf_ball(.5); >> for i=1:401, y(:,i) = A*x(:,i); end >> plot(x(1,:),x(2,:),'-') >> subplot(2,2,4) >> hold on >> plot(y(1,:),y(2,:),'-') >> subplot(2,2,3) >> hold on >> [x] = Linf_ball(1); >> for i=1:401, y(:,i) = A*x(:,i); end >> plot(x(1,:),x(2,:),'--') >> subplot(2,2,4) >> plot(y(1,:),y(2,:),'--') >> subplot(2,2,3) >> [x] = Linf_ball(1.5); >> for i=1:401, y(:,i) = A*x(:,i); end >> plot(x(1,:),x(2,:),'-.') >> subplot(2,2,4) >> plot(y(1,:),y(2,:),'-.') >> title('A applied to balls in L_{inf}') >> subplot(2,2,3) >> title('Balls in L_{inf}') >> subplot(2,2,4) >> axis([-2.6,2.6,-2.6,2.6]) >> subplot(2,2,2) >> axis([-2.6,2.6,-2.6,2.6]) >> print -dps fig2.ps >> quit 95559 flops.