How to group a matrix based on height

1 回表示 (過去 30 日間)
R MONTGOMERY
R MONTGOMERY 2019 年 3 月 17 日
回答済み: Akira Agata 2019 年 4 月 8 日
EDIT __________
my apolgies for confusion
Say I have a matrix of nx1 as such:
[..... 2.59, 2.6, 2.6, 1.7 , ....... , 1.8 , 2.57 , 2.6, 2.7, 1.8.....]
(block 1) (block 2)
Is there a function that groups that first "block" of values over 2.5 as "block 1" and then the second "block" of values over 2.5 as another thing such as "block 2"
my apologies I appreciate your help
  3 件のコメント
Image Analyst
Image Analyst 2019 年 3 月 17 日
We're not going to type that in. Please attach the data with the paperclip icon. Make it easy for people to help you, not hard.
R MONTGOMERY
R MONTGOMERY 2019 年 3 月 17 日
Im sorry Im not very clear.
Let me ask this instead as my english skills are not so great.
Say I have a matrix of nx1 as such:
[..... 2.59, 2.6, 2.6, 1.9 , ....... , 1.9 , 2.57 , 2.6......]
Is there a function that groups that first "block" of values over 2.5 as "block 1" and then the second "block" of values over 2.5 as another thing such as "block 2"
my apologees I appreciate your help

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

回答 (1 件)

Akira Agata
Akira Agata 2019 年 4 月 8 日
If you have Image Processing Toolbox, you can do this task easier by using bwlabel function. The following is a simple example.
nx1 = [1.1, 2.59, 2.6, 2.6, 1.7, 1.8, 2.57, 2.6, 2.7, 1.8];
idx = nx1 > 2.5;
group = bwlabel(idx);
The result is like:
>> group
group =
0 1 1 1 0 0 2 2 2 0

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by