In: Computer Science
I was asked to create a function called mydrawing in Matlab to draw or plot lines onto a graph, using a so called pen.
The pen will start at the origin and will move along the +ve horizontal axis. The pen is also supplied with a list of commands in a form of a string, to draw or plot the lines onto the graph. The string commands are:
1) 'F' : the pen moves forward by x = 1.0
2) 'R' : the pen will turn right by a known angle
3) 'L' : the pen will turn left by a known angle
This function is written in such a way that if I type mydrawing(*insert the string*, *insert the angle*), I could draw or plot a square in the graph.
How do I code for these functions in Matlab?