Creating cell array for values in a signal vector that cross a certain threshold
古いコメントを表示
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
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
2020 年 10 月 14 日
Image Analyst
2020 年 10 月 14 日
It creates a cell array with the elements (indexes) right before where the signal crosses from
- below 10 to above 10, and
- above 10 to below 10
So you'd take those indexes and add 1 to get the index right after they crossed 10 - in other words on the other side. Then do a simple blinear interpolation to get the interpolated values at exactly 10. You can do that part, right?
Kimberly Cardillo
2020 年 10 月 14 日
Kimberly Cardillo
2020 年 10 月 14 日
Image Analyst
2020 年 10 月 14 日
You forgot to attach your script and data (aefm_4), so how can we debug your program for you???
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!