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

1 回表示 (過去 30 日間)
BA 2022 年 7 月 30 日

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?

サインインしてコメントする。

### 回答 (1 件)

Varun 2023 年 9 月 1 日
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

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by