%plot a rect function as a perspective plot clear all; close all; N=51; %generate an N by N array of points x=0:(1/(N-1)):1; y=x; % x and y values between 0 and +1 spaced by 1/(N-1) (N values) [X,Y]=meshgrid(x,y); % generate 2D grids of xy values (51 by 51 arrays) X(i,j) = x(j) and Y(i,j) = y(i) Z = zeros(N,N); Z(abs(X-0.5) < 0.15 & abs(Y-0.5) < 0.2) = 1; mesh(X,Y,Z) % generate the perspective plot colormap([0 0 0]); % use black only xlabel('x (ph)'), ylabel('y (ph)'); set(gca,'ydir','reverse'); figure,imshow(Z)