Using arrays, x and y coordinates, to calculate values for each pair of x and y

조회 수: 9 (최근 30일)
ally essy
ally essy 2022년 5월 19일
편집: ally essy 2022년 5월 19일
Hi, so I've got my code, my equation and I am trying to link together my x and y array to my equation. Theres 4 points on a grid with set intervals between them and I'm trying to find the longest and shortest distance between them.
So my question is, how can I make it so I get every pair of value for D(x,y) in this grid using the discrtisation points, and then get the smallest distance (D) and also for the code to spit out the shortest value for D(x,y) with the correspoinding length and the same for the longest distance. I'm just not sure how to link my array points with the discretisations point to the equation.
For example at x = 6.08 and at y = 17.62 the length was smallest length where D = 23.42 (example length)
For example at x = 12.08 and at y = 25.62 the length was largest length where D = 32.32 (example length)
x = 0:0.02:20;
y = 0:0.02:30;
[X,Y] = meshgrid(x, y);
D = sqrt(4-x)^2 + (3-y)^2 + sqrt(6-x)^2 + (22-y)^2 + sqrt(10-x)^2 + (6-y)^2 + sqrt(18-x)^2 + (28-y)^2
Thanks for the help! :)

답변 (1개)

KSSV
KSSV 2022년 5월 19일
What I can understand is, you can make use of knnsearch, rangesearch

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by