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

조회 수: 1 (최근 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