If your myFunction not designed to handle the input of the matrix, you can use the ARRAYFUN function to apply it to all the corresponding x and y entries:
[x,y] = meshgrid(0:0.5:3); %# Create a mesh of x and y points z = arrayfun(@myFunction,x,y); %# Compute z (same size as x and y)
You can then use the CONTOUR function to create a contour graph for the above data. Since your z data has only 2 different values, it will probably be useful for you to only build one contour level (which will have a value of 0.5, halfway between your two values). You can also use the CONTOURF function, which creates color-filled paths that clearly show where those and zeros are:
contourf(x,y,z,1); %
NOTE. . Since you are drawing data that has only ones and zeros, plotting outlines might not be the best way to render. Instead, I would use something like the IMAGESC function, for example:
imagesc(x(1,:),y(:,1),z);
Remember that the y axis in this graph will be changed relative to the plot created by CONTOURF .
source share