RectRange

バージョン 1.0.0 (14.5 KB) 作成者: Chi
a MATLAB function for obtaining coordinate range of a selected rectangle in figure
ダウンロード: 74
更新 2018/7/29

Warning! Do not use this function upon your final prepared/optimized figure, because it will manipulate Axes Aspect Ratio.

[Xrange,Yrange]=rectrange(xgrid,ygrid,f) lets you select a rectangle in the current figure using the mouse. The figure has to be generated based on a rectangle grid (X, Y) which is usually produced by using function MESHGRID. Then the coordinate ranges of the selected rectangle (Not its position.Thus, its different from function GETRECT) based on grid (xgrid,ygrid) will be derived.This would be useful when you have a map generated based on grids of longitudes and latitudes and want to know longitude/latitude range of a certain region. However, this function won't work when the map is produced by using M_Map toolbox due to projection issues.

Inputs

xgrid,ygrid - The rectangle grid on which the figure bases. Usually, they are generated by [xgrid,ygrid]=meshgrid(xgv,ygv). See meshgrid.m.

f - The handle of the figure. For exmaple, f = figure;

'precise' - Default output mode. The precise coordinate ranges will be obtained no matter there are intervals between grid points.

'nearest' - Other than 'presice', the coordinate ranges of your selected rectangle in x- and y-direction will be derived from 4 grid points close to each vertex of the rectangle.

Outputs

Xrange - The range of selected rectangle in x-direction.

Yrange - The range of selected rectangle in y-direction.

For example,

[X,Y,Z] = peaks;
f=figure;
contourf(X,Y,Z,'linestyle','none');
axis equal
[rx,ry]=rectrange(x,y,f);

One can test this function by uncommenting lines 106, 107, 125-128, 133-134 and 145. The rectangle you selected and its two vertices will be drawn in your figure.

引用

Chi (2026). RectRange (https://github.com/chouj/RectRange), GitHub. に取得済み.

MATLAB リリースの互換性
作成: R2015a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

GitHub の既定のブランチを使用するバージョンはダウンロードできません

バージョン 公開済み リリース ノート
1.0.0

この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。