Prompt 'The Farthest Vertex of The Rectangle (X Y) :'
Prompt 'The Farthest Vertex of The Rectangle (X Y) :'
clc
prompt =
'The farthest vertex of the rectangle [x y]:'
x3 = input(prompt);
prompt = 'Specify any point outside the rectangle [x y z]'
prompt =
'Specify any point outside the rectangle [x y z]'
q = input(prompt);
x1 = [0 0];
x2 = [x3(1) 0];
x4 = [0 x3(2)];
display(x1);
x1 = 1×2
0 0
display(x2);
x2 = 1×2
10 0
display(x3);
x3 = 1×2
10 6
display(x4);
x4 = 1×2
0 6
X = 0:1:x3(1);
Y = 0:1:x3(2);
display(X);
X = 1×11
0 1 2 3 4 5 6 7 8 9 10
display(Y);
Y = 1×7
0 1 2 3 4 5 6
I = 0;
for i = X(1) : X(x3(1))
1
for j = Y(1) : Y(x3(2))
rectangle('Position',[i j 1 1]);
xn = (i+i-1)/2;
yn = (j+j-1)/2;
di = sqrt((q(1)-xn)^2 + (q(2)-yn)^2 + (q(3)^2));
u = 1/di;
I = I + u;
end
end
display(I);
I = 0.9957