How to draw a grid in Matlab?

The Nebs

New member
I've been sitting like 3 hours using multiple codes in order to get this to work. This is the most I came up with:

function plot_grid(ax,bx,ay,by,nx,ny)
axis([ax bx ay by])
xi = 0:ax;
yi = 0:ay;
xf = bx;
yf = by;

nx = plot([xi;xf],[yi,yf]);

All this draws is a diagonal line. Help would be greatly appreciated!!!!!

1. Draw a grid using the technique to draw multiple non-connected lines.
The specification of the function m-file is as follows:

function plot_grid(ax,bx,ay,by,nx,ny)
ax: minimum value of x
bx; maximum value of x
ay: minimum value of y
by: maximum value of y
nx: number of horizontal intervals between ax and ay
ny: number of vertical intervals between by ay and by
Example of the plot:
>> plot_grid(0,10,0,10,10,10)
 
Back
Top