Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello i need help writing this program in matlab... thanks in advance Write a MA

ID: 1846107 • Letter: H

Question

hello i need help writing this program in matlab... thanks in advance

Write a MATLAB program to build a standard English dartboard onto a Cartesian grid with 512 times 512 points. This should be a single array with values assisgned to each point in a manner that describes the dartboard. You do not have to account for the wires between regions on the board. Image the data in your array to a figure window and include the image in your homework solution. Remember to include your MATLAB code in an Appendix. Hints: Use meshgrid ( ). Use atan2 ( ). Your data should look like the figure to the right. Do not use for loops to fill in pixels in your grid.

Explanation / Answer

%___________Standard English Dartboard__________%

%_________________________________________________________________________

clc;

close all;

clear all;

%_________Twenty Sectors required to create________________________________

W=pi/20;

xa = linspace(-1,1,512);

ya = linspace(-1,1,512);

%______Inserting circles of different radii________________________________

R=[10 22 179 213 307 331 ]./512;

[Y,X] = meshgrid(ya,xa);

D1 = X.^2 + Y.^2<=R(1);

D2 = X.^2 + Y.^2<=R(2);

D3 = X.^2 + Y.^2<=R(3);

D4 = X.^2 + Y.^2<=R(4);

D5 = X.^2 + Y.^2<=R(5);

D6 = X.^2 + Y.^2<=R(6);

%_______Designing of alternating 'wedges' having twenty sectors____________

wedge1=((atan2(Y,X)<=W)+(-W<=atan2(Y,X)))-1;

wedge2=((atan2(Y,X)<=5*W)+(3*W<=atan2(Y,X)))-1;

wedge3=((atan2(Y,X)<=9*W)+(7*W<=atan2(Y,X)))-1;

wedge4=((atan2(Y,X)<=13*W)+(11*W<=atan2(Y,X)))-1;

wedge5=((atan2(Y,X)<=17*W)+(15*W<=atan2(Y,X)))-1;

wedge6=flipud(wedge1);

wedge7=rot90(wedge2,2);

wedge8=rot90(wedge3,2);

wedge9=rot90(wedge4,2);

wedge10=rot90(wedge5,2);

%_________Summing up all wedges so we get matrix of wedges_________________

wedge=wedge1+wedge2+wedge3+wedge4+wedge5+...

wedge6+wedge7+wedge8+wedge9+wedge10;

%_______DartBoard________Creation________Matrix____________________________

D=(50.*D1+25.*(D2-D1)+20.*(D3-D2).*wedge+60.*(D4-D3).*wedge+20.*...

(D5-D4).*wedge+40.*(D6-D5));

%_________Figure Showing Dartboard_________________________________________

figure('Color','b');

imagesc(xa,ya,D)

title('DARTBOARD','fontsize',14)

colorbar

shading interp;

axis equal tight;