Using arrays, x and y coordinates, to calculate values for each pair of x and y
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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! :)
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!