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
2 次查看(过去 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)));
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!