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

Starting with a 20 x 20 matrix, write a program in Matlab where the COMPUTER PLA

ID: 3579832 • Letter: S

Question

Starting with a 20 x 20 matrix, write a program in Matlab where the COMPUTER PLAYS THE GAME. The USER answers two inputs: x=input('what is the x location of the object?') y=input('what is the y location of the object?') YOU WRITE THE PROGRAM SO THAT THE COMPUTER PLAYS THE GAME.. *Start with a 20 by 20 matrix.* Pick a starting point. Calculate the distance to the object. Pick another point, calculate the distance to the object. Asking only which point was closer, you pick your next location and calculate distance. Keep going until distance is less than .5.

Explanation / Answer

clear all
m = zeros(20,20);
x=5;
y=5;
dm = zeros(20,20);
for row=1:20
for col=1:20
p = [row,col;x,y];
fprintf('%d : %d',row,col);
d = pdist(p,'euclidean');
dm(row,col)=d;
end
end
dm

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote