0% found this document useful (0 votes)
41 views2 pages

Prompt 'The Farthest Vertex of The Rectangle (X Y) :'

The document describes creating a rectangle based on user input for its farthest vertex and then calculating the inverse distance sum of a point outside the rectangle to points within the rectangle. It prompts the user for the coordinates of the farthest rectangle vertex and a point outside. It then displays the rectangle vertices, draws the rectangle, iterates through points within using nested for loops, calculates the inverse distance of each interior point to the exterior point, and sums these values.

Uploaded by

Victor Daggers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

Prompt 'The Farthest Vertex of The Rectangle (X Y) :'

The document describes creating a rectangle based on user input for its farthest vertex and then calculating the inverse distance sum of a point outside the rectangle to points within the rectangle. It prompts the user for the coordinates of the farthest rectangle vertex and a point outside. It then displays the rectangle vertices, draws the rectangle, iterates through points within using nested for loops, calculates the inverse distance of each interior point to the exterior point, and sums these values.

Uploaded by

Victor Daggers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

clear all

clc

prompt = 'The farthest vertex of the rectangle [x y]:'

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

rectangle('Position',[0 0 x3(1) x3(2)]);

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

You might also like