Starting with a 20 x 20 matrix, write a program in Matlab where the COMPUTER PLA
ID: 3577832 • 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.