Creating cell array for values in a signal vector that cross a certain threshold

2 次查看(过去 30 天)
I have a 1599 x 54 double matrix called aefm_4 were the columns represent observations (signals) and the rows represent time steps. For each column, I want to find the row number where the value is equal to 10. For example, I have a signal (whose signal vector is a certain column number in the matrix) as seen in the picture below and I want to find the x values (row number) of where the threshold (red line) and signal (blue line) cross. Not every signal will cross this threshold exactly 10 times, thats why I want to make it a cell array. Also, the y values wont be at exactly y=10 so i need to find the values directly above and below y=10 and then interpolate. If anyone could help me with this or at least get me started, that would be great.

回答(1 个)

Image Analyst
Image Analyst 2020-10-13
Is this homework?
Here's a start. It gives you the elements just before where it crosses 10. Take the element after and do a blinear interpolation with interp1. I trust you can do that but let us know if you can't figure it out after a good attempt.
data = 100 * rand(1599, 44) - 50;
[rows, columns] = size(data);
for col = 1 : columns
thisColumn = data(:, col);
plot(thisColumn, 'b-');
% Draw threshold.
yline(10, 'Color', 'r', 'LineWidth', 2);
% Draw y axis.
yline(0, 'Color', 'k', 'LineWidth', 2);
drawnow;
risingIndexes{col} = strfind(thisColumn' > 10, [0, 1]);
fallingIndexes{col} = strfind(thisColumn' > 10, [1, 0]);
end
  5 个评论
Kimberly Cardillo
Kimberly Cardillo 2020-10-14
I ran the code with data = aefm_4; and i get the error, unable to perform assignment because brace indexing is not supported for variables of this type
Image Analyst
Image Analyst 2020-10-14
You forgot to attach your script and data (aefm_4), so how can we debug your program for you???

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by