フィルターのクリア

How to find the element in on boundary or interior?

2 ビュー (過去 30 日間)
Anusha
Anusha 2014 年 4 月 7 日
回答済み: Jos (10584) 2014 年 4 月 7 日
a=[3 4 5;6 1 2]
I want to know if the element 2 is on boundary or interior?
how will i check?
  2 件のコメント
Image Analyst
Image Analyst 2014 年 4 月 7 日
When a is a 2 by 3 matrix:
a =
3 4 5
6 1 2
Exactly which pixels do you consider to be interior and which to be exterior/boundary? The all look like boundary pixels to me.
Jos (10584)
Jos (10584) 2014 年 4 月 7 日
Boundary of what ?

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

採用された回答

Jos (10584)
Jos (10584) 2014 年 4 月 7 日
tf = false(size(a))
tf(2:end-1,2:end-1) = true
a(tf) % elements in interior
a(~tf) % elements on boundary

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 4 月 7 日
What is element 2? The lower right element with the value of 2? Or row=2, column = 1 which is how the column major order of MATLAB defines the second element? Can't you just look at the row and column and see if it's equal to 1 or the total number of rows or columns in the matrix?

Alberto
Alberto 2014 年 4 月 7 日
編集済み: Alberto 2014 年 4 月 7 日
If you suppose there is only one value 2 in the matrix, this code may be useful:
a=[3 4 5;6 2 1; 1 6 9] % interior value % a=[3 4 5;6 1 2; 1 6 9] % edge value [nrow ncol]= size(a) % Obtain dimensions
% find(a==2) extract linear index, so you better convert to subindices [I,J] = ind2sub(size(a),find(a==2))
% and checking if I==1 J==1 I==nrow J==ncol display('In the edge') else display('interior value')
end
% If there are other 2 values you should create a for across the I and J vectors.
a=[3 4 5;6 2 1; 2 6 9];
[nrow ncol]= size(a); [I,J] = ind2sub(size(a),find(a==2));
for k=1:length(I) if I(k)==1 J(k)==1 I(k)==nrow J(k)==ncol display(['In the edge ( ', num2str(I(k)), ', ', num2str(J(k)), ' )'])
else display(['Interior value ( ', num2str(I(k)), ', ', num2str(J(k)), ' )'])
end
end
  1 件のコメント
Anusha
Anusha 2014 年 4 月 7 日
a=[3 4 5; 6 7 8; 9 0 1]
if i want to identify the element to check if the element is boundary or interior
This example 7 is a interior node and other element are boundary
How to check this node

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

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by