The purpose of this problem is to draw a grid using the tech

The purpose of this problem is to draw a grid using the technique to draw multiple non-connected lines The method was discussed in Pr. 11 of Lab Assignment (LA) #1 Instructions: Produce a grid consisting of nx+1 equally spaced vertical lines that produce nx equally spaced intervals AND ny+1 equally spaced horizontal lines that produce my equally spaced intervals. These multiple lines produce a grid The minimum and the maximum values of the x-coordinate, in the grid, are ax and bx, respectively. Similarly, the minimum and the maximum values of the y-coordinates are ay and by, respectively. Notice that the horizontal and the vertical intervals may not be equal. First, write a function m-file with the specification 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 (a) Make sure to use a single color for all lines By default, you get multiple colors for multiple lines (b) Also shift the grid inside the MATLAB drawing plane so that we can see the outer frame of the grid. Without this, the outer the left and right most vertical lines in the grid coincides with the outer frame of the figure and are not distinguishable. Similar inconvenience happens to the bottom and the top horizontal lines of the grid (c) Use die command plot_grid(0, 10, 0, 10, 10, 10) Next try >> plot_grid(1, 11, -1, 9, 5, 10) (a) Optionally try other inputs to show your code is correct (b) Insert, in the answer, the plots produced and submit at sakai

Solution

Answer :

% Function to print the grid
function grid = plot_grid(ax,bx,ay,by,nx,ny)
figure; hold on;axis equal;
for idx = ax : (bx-ax)/nx : bx
% \'Color\' for specifying single color
grid= plot([idx idx], [ax bx], \'Color\', \'b\');
end
for idx = ay : (by-ay)/ny : by
grid= plot([ay by], [idx idx], \'Color\', \'b\');
end
% set(grid, \'PaperSize\', [20 20]);
end

plot_grid(0,10,0,10,10,10);

print grid;

Comment : Kindly find the solution for b by yourself. Other than b you got all the questions answered. Check the comments in the code then and there to understand it.

 The purpose of this problem is to draw a grid using the technique to draw multiple non-connected lines The method was discussed in Pr. 11 of Lab Assignment (LA

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site