필터 지우기
필터 지우기

Finding zeroes of data for multiple trials

조회 수: 2 (최근 30일)
LRW
LRW 2020년 12월 21일
답변: Image Analyst 2020년 12월 21일
I have found that the answer to another question on MATLAB Answers (found here: Previous Question) works for finding the zeroes of one of my data trials (see code below).
x = QF02num(:,1);
y = QF02num (:,2);
%%Code is from Star Strider in Previous Question (see link above)
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
dy = zci(y); % Indices of Approximate Zero-Crossings
for k1 = 1:size(dy,1)-1
b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); y(dy(k1)+1)]; % Linear Fit Near Zero-Crossings
x0(k1) = -b(1)/b(2); % Interpolate :Exact, Zero Crossing
mb(:,k1) = b; % Store Parameter Estimates (Optional)
end
However, my data consists of multiple trials. I have a matrix called QF02num(91X81) that has 81 trials of data for which I am wanting to find the zeroes. The length of these trials (or the number of rows) and the number of times the data will cross the x axis both vary from trial to trial.
I have tried adding a for loop to iteratively go through each column or trial but I'm not sure how to store the zeroes (x0) for all the trials into one matrix. How do I make it so x0 stores the values of each iteration or column (i)?
for i=size(QF02num,2);
x = QF02num(:,1);
y = QF02num (:,i);
%%Code is from Star Strider in Previous Question (see link above)
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
dy = zci(y); % Indices of Approximate Zero-Crossings
for k1 = 1:size(dy,1)-1
b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); y(dy(k1)+1)]; % Linear Fit Near Zero-Crossings
x0(k1) = -b(1)/b(2); % Interpolate :Exact, Zero Crossing
mb(:,k1) = b; % Store Parameter Estimates (Optional)
end
end
I have included a plot of one of the trials for visualization:

답변 (1개)

Image Analyst
Image Analyst 2020년 12월 21일
Assuming mb is your signal that you plotted, you can count the number of regions where the signal is above zero with this:
[, count] = bwlabel(mb > 0);

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by