2017-05-13 14 views

答えて

0

あなたのマトリクスエントリは位置エントリであると仮定しますか?そうでない場合は、2D行列のサイズで2つの行列xとyを作成し、それらを参照として取得します。

% create matrix 
[x,y] = meshgrid(1:50); 

% cropped matrix 
x_crop = x(20:45,10:30); 
y_crop = y(20:45,10:30); 

% position in full-size matrix 
pos = [25, 23]; % [x-coordinate, y-coordinate] 

% get minimum and maximum positions of x_crop and y_crop 
xmin = min(x_crop(:)); 
xmax = max(x_crop(:)); 

ymin = min(y_crop(:)); 
ymax = max(y_crop(:)); 

% Check if pos is inside minima/maxima 
if pos(1)>= xmin && pos(1)<= xmax && pos(2)>=ymin && pos(2)<=ymax 
    is_in = true; 
else 
    is_in = false; 
end 

is_in 

希望に応じます。また、私はあなたの質問を理解しています:D

関連する問題