Question: Write a Matlab script called yourlastname _ 8 _ 1 . m which creates and plots a 2 - D array of points that represent
Write a Matlab script called yourlastname which creates and plots a D array of points that represent a two dimensional shape as described below. Using the lecture example boxdemom available on Monday's Brightspace site as a guide, your script must include:
A "main" function which clears the command window clc clears all workspace variables clear all and closes all open figure windows close all; declares the variables and color to be global; defines a design space by setting and ; initializes arrays and color to false and char respectively.
Commands to create the following shapes:
a red circle of radius, centered at
a green box with and
a circular hole of radius centered at
For the box, use the function boxD available in the file boxdemom For the circles, add a new function called circle which is called using the command
function circle xC yc R D C
where is the coordinate of the center of the circle, is the radius of the circle, is a logical true or false true to add points, false to remove points and is the desired color rg etc. Within the function, include two nested loops in which the distance from each point to the center of the circle, given by is computed and, if the distance is less than or equal to the corresponding is set to true and color is set to Include the main program and both functions in the same file yourlastnamem
Display the resulting shape using the plot command within two nested for loops, as done in boxdemom
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
