# Any suggestions to measure the distance between two lines or regions (the dip represents low intensity)

1 visualizzazione (ultimi 30 giorni)
BA il 30 Lug 2022
Risposto: Varun il 1 Set 2023
Here I plotted the centre of gravity between two regions, then I would like to measure the distance between these two line using gridline or region of interest, maybe , any suggestions?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Varun il 1 Set 2023
Hello!
As per my understanding, you want to measure the distance between two lines that have been plotted in the figure. There are multiple ways to go about it:
1. Using the “drawline function: The “drawline” function lets you create a customizable region-of-interest. So, in the figure window, you can measure the distance between the lines by connecting the lines using “drawline”, by placing one end-point on each line. The line’s Position properties can be used to get the coordinates of its endpoints, using which the Euclidean distance can be calculated. Example:
h1 = drawline();
distance=sqrt((h1.Position(1,1)-h1.Position(2,1))^2 + (h1.Position(1,2)-h1.Position(2,2))^2);
2. Using the “ginput” function: The “ginput” function lets you identify axes coordinates in a Figure window. So, “ginput” can be used to pick two points, one lying on each line. Using the coordinates of these points, the Euclidean distance can be calculated. Example:
disp('Select a point on Line 1:');
[x1_point, y1_point] = ginput(1);
scatter(x1_point, y1_point)
% Select points on Line 2
disp('Select a point on Line 2:');
[x2_point, y2_point] = ginput(1);
scatter(x2_point, y2_point);
% Calculate the distance between the selected points
distance = sqrt((x2_point - x1_point^2 + (y2_point- y1_point)^2);
Hope this helps!
Thanks,
Varun
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Visual Exploration in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by