finding neighbouring locations in matrix bigger than a certain value

2 ビュー (過去 30 日間)
Johannes Deelstra
Johannes Deelstra 2020 年 11 月 23 日
編集済み: Alan Moses 2020 年 12 月 1 日
Hey
I have a 324 x 1 matrix
I like to find the neighbouring cells having each a value bigger than for example 50
Or how to I find the locations ofg three neighbouring cells bigger than 50
thanks in advance

回答 (1 件)

Alan Moses
Alan Moses 2020 年 12 月 1 日
編集済み: Alan Moses 2020 年 12 月 1 日
You may refer the method used here to find the neighbouring values of an element in a matrix. To find the locations of elements in a vector, you may refer the find function.
You may also refer the example below that finds neighbouring cells for values greater than 50. The code can be modified to find neighbours greater than 50 as well.
>> A = [3;4;8;6;51;5;8;65;9]; % size - 9x1
>> M = zeros(size(A.'));
>> C = find(A>50);
>> M(1,C) = 1;
>> Neighbours = A(conv2(M,[1,1,1;1,0,1;1,1,1],'same')>0)
Neighbours =
6
5
8
9

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by