Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Be unique and creative (for #2&3) COMPLETE COMPLETELY IN MATLAB {x=Rcos+x0y=Rsin+y0where02 Write a function, fn_DrawShape, which input the coordinate of center of the circle as

Be unique and creative (for #2&3)

COMPLETE COMPLETELY IN MATLAB

image text in transcribedimage text in transcribedimage text in transcribed {x=Rcos+x0y=Rsin+y0where02 Write a function, fn_DrawShape, which input the coordinate of center of the circle as a vector (c0), radius (R), the number of points (n) that user wants to create, and color set-up (colors), and draw the shape by using line function. In the function, you must create at least 2 points and connect each other till all the points are connected. (Therefore, if you plot triangle, you need to generate 4 points.) The fn_DrawShape doesn't have to have output arguments. Function should be called as >> fn_DrawShape(CO, R, n, colors) fn_DrawShape should use plotting function, plot or line to connect the points and set the color in the input, so user can set the color. This function just creates (draws) one shape depending on user's choice. For example, when center is [0,0], and radius is 1 , draw triangle is: >> fn_DrawCircle([0, 0], 1, 4, 'b') NOTE: 1ST point and last point are same as 02. Write a script, DrawShape, by calling fn_DrawShape and draw the sequential shapes (see the example) by using for loop or while loop. Script should prompt user to input CO, R, n, and color set-up, and may ask how many shapes to draw (your script can set this as a default). To change the color, you may use colormap and select the choice of color in the loop to change. Modify the example script to generate the following shapes. Hint: You need to change the radius and center in the loop. (5pt) \%Example of Extra Credit center = input('Input the main center you want as a vector: '); radius = input('Input the main radius you want: '); n = input('Enter amount of points of shape. Must be larger than 3: '); n=n+1; \%last point must come back to the original points. Thus, the function generates 4 points based on this input. N= input('How many shapes to generate?: '); color_choice=round(linspace (1,256,N)); for i=1:N fn_DrawCircle(center,radius, n+(i1), colors(color_choice(i),::)) axis equal hold on end This function draws one shape based on the inputs. Function should generate x,y coordinates accordingly, 3. Write a script, DrawShape_extra, by calling fn_DrawShape and draw any the sequential shapes (see the example) by using for loop or while loop You can create any unique shapes and change colors! Be creative! (5pt)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions