Extract certain data from array where repeats are present (but constant values)

Hello, I have some data where I my relevant column (Y position) is as this yellow graph
I want to pull out just the data that is between the green arrows - I do know the actual starting and finishing Y positions (101 and 121 respectively) , but there are other values at these values - but they are constant
My data is actually in an array, and the Yposition is column 2, but I delete the 1st column, so the column becomes 1
this was my attempt to remove all rows of my array outside of these green arrows.
% Get user input to the real starting and finishing Y values
prompt = {'Col:','start:','finish:'};
dlgtitle = 'Keep Rows Between';
dims = [1 35];
definput = {'1','101','121'}; % definput = {'Region:',num2str(X),num2str(Y)};
answer = inputdlg(prompt,dlgtitle,dims,definput);
col=str2num(answer{1}); low=str2num(answer{2}); high=str2num(answer{3});
% Get Current table data
t=app.UITable;
d=t.Data;
d=rmmissing(d); % One wat Remove Nans
Y=table2array(d);
Y=Y(:,col);
low
head(Y)
class(Y)
% Get index of
idx1=find(Y<=low);
idx2=find(Y>=high);
size(idx1)
size(idx2)
id=[idx1;idx2];
d(id,:)=[];
t.Data=d;
However, this keeps all values not just within the greena rrows.
I have included my data

 採用された回答

Matt J
Matt J 2025 年 6 月 23 日
編集済み: Matt J 2025 年 6 月 23 日
Why not as follows,
low= find(Y==min(Y),1,'last');
high=find(Y==max(Y),1,'first');
d=d(low:high,:);

4 件のコメント

Walter Roberson
Walter Roberson 2025 年 6 月 23 日
It is not immediately obvious to me that the data will definitely end up higher than than the lower bump. Perhaps that will always be the case, but I don't know that for certain.
Jason
Jason 2025 年 6 月 23 日
Yes thats my concern. what is true, is for the values I want (in between the green lines, the value is always higher than the previous one
Matt J
Matt J 2025 年 6 月 23 日
編集済み: Matt J 2025 年 6 月 23 日
Then, perhaps,
dY=gradient(Y);
low= find(Y==min(Y),1,'last');
high=find(dY==max(dY),1,'last');
d=d(low:high,:);
Jason
Jason 2025 年 6 月 23 日
Thanks Matt

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

製品

リリース

R2024b

質問済み:

2025 年 6 月 23 日

コメント済み:

2025 年 6 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by