How to plot a grid with a for loop.
50 views (last 30 days)
I am trying to design a program which must be able to plot a grid (of dost for example in this specific case).
So the user enters the value n of the number of dots that the grid must have (I have entered here 46 as an example) and now the program must draw all the dots beggining with one knew dot (the dot 0).
From the coordinates of that knew dot, the following ones (until the n-th one, that is, until the 46-th one) must be drawn by adding 1 to the X coordinate of the previous one and adding 3 to the Y coordinate of the previous one.
I have tried to design that program in the following code (with a for loop) but it doesn`t work, it seems that matlab doesn't recognize that notation that I have written in the 7-th and 8-th lines of code..
dot(0)=[6,6]; %The first dot of all (knew)
for 1:46 %I want to draw up to n dots (46 for example)
dot(i)(1)=dot(j)(1)+1; %The i-th dot's X coordinate is the previous dot's X coordinate +1
dot(i)(2)=dot(j)(2)+3; %The i-th dot's Y coordinate is the previous dot's Y coordinate +3
Anyone knows how program it in the correct way?
Anyone knows the correct way of writing those 7-th and 8-th line of code?
Thanks very much to everyone.