I have a signal and have marked and plot any points that exceed a power threshold. How can I create a new array of the data points that exceed the threshold? The distance between each point is differs slightly so I can't just write x:y:z
1 回表示 (過去 30 日間)
古いコメントを表示
The distance between each point is differs slightly so I can't just write x:y:z. I need to just take exactly the points above the threshold and put them into an array.
The array is from over_x(1):over_x(end), but I don't know how to include all the points in between.
Thanks in advance
2 件のコメント
dpb
2017 年 6 月 19 日
If over_x is the array of points
over_x=x(x>threshold);
then you've already got it.
The expression over_x(1):over_x(end) is shorthand for over_x(1):over_x(length(over_x)) and is equivalent to just writing over_x without any subscript expression.
Not sure what the issue is, precisely??? Can you explain more of what the difficulty is you're having?
回答 (1 件)
Jan
2017 年 6 月 19 日
編集済み: Jan
2017 年 6 月 19 日
You forgot to mention, how your data are available. If I guess this detail, it might differ from your setup and confuse you. But I try it:
t = sort(rand(1, 1000)); % The non-uniform x values
y = bsxfun(@plus, rand(1, 1000), linspace(0, 2, 1000));
figure;
subplot(1,2,1);
plot(t, y);
Now get all values above a limit:
index = (y > 2);
subplot(1,2,2);
plot(t(index), y(index));
Or perhaps you want to get all values from the first value above the limit to the last one? The question is not clear in this point.
index = find(y > 2);
plot(t(index(1):index(end)), y(index(1):index(end)));
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!