Computing distances between nodes (intersections of a grid 40x40) and 21 points located in the cell regions in between the nodes.

2 views (last 30 days)
I am trying to write a script where I take a 2000m x 2000m area broken into a grid where by the grid elements are 50m x 50m. In 21 different location i need to place
sources in the center of particular grid elements and then compute the radial distances from each source location to every node on the grid, so I should be getting
41x41x21= 35301 distances in a logical array as a result. I have been palying with the the script shown below but it is obviously wrong as it returns only 21x41= 861
distances. Can any one help with a suggestion of a different approach ?
close all;
clc;
clear;
X= [225 725 1375 1575 425 1675 475 775 1225 1625 1775 1325 1375 1575 975 725 625 875 125 1575 125]';
YX= [425 425 625 1125 1475 1775 1225 775 775 775 325 1275 275 425 1275 1275 1425 1425 1875 1875 425]';
XP= [0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 1900 1950 2000];
YP= [0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 1900 1950 2000];
Xdist = X(:) - XP(:)';
Ydist = YX(:) - YP(:)';
dist = sqrt(Xdist.^2 + Ydist.^2);
  3 Comments
steven elliott
steven elliott on 25 Oct 2020
Hi Walter.
Yer so 40 x 40 cells and all line intersections including corners as nodes. such that the distance from the center of each element has a non zero distance to all of the nodes if that makes sense.

Sign in to comment.

Accepted Answer

steven elliott
steven elliott on 25 Oct 2020

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!