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_8_1.m which creates and plots a 2-D array of points that represent a two dimensional shape as described below. Using the lecture example box_demo_1.m (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 Nx,NY,d and color to be global; defines a 5050 design space by setting Nx=50 and NY=50; initializes NYNx arrays d and color to false and char (0), respectively.
Commands to create the following shapes:
a red circle of radius, R=15, centered at x=y=25
a green box with 17x33 and 17y33
a circular hole of radius R=5, centered at x=25,y=25
For the box, use the function box2D (available in the file box_demo_1.m). For the circles, add a new function called circle which is called using the command
function circle (xC, yc, R, D, C)
where (xC,yc) is the coordinate of the center of the circle, R is the radius of the circle, D is a logical true or false (true to add points, false to remove points) and C is the desired color ('r','g', etc.). Within the function, include two nested loops in which the distance from each (x,y) point to the center of the circle, given by (x-xc)2+(y-yc)22, is computed and, if the distance is less than or equal to R, the corresponding d(i,j) is set to true and color(i,j) is set to C. Include the main program and both functions in the same file (yourlastname_8_1.m)
Display the resulting shape using the plot command within two nested for loops, as done in box_demo_1.m
Write a Matlab script called yourlastname _ 8 _ 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!