필터 지우기
필터 지우기

Zero Crossing of Signal - Misunderstanding the attached matlab code.

조회 수: 7 (최근 30일)
Jimmy cho
Jimmy cho 2020년 12월 22일
댓글: Star Strider 2021년 1월 9일
Hi guys!
Im trying to understand the zero crossing points that uses interpolation approximation which I found the code here in the threads of matlab.
the code that I found it is this:
x=1:length(y);
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
I almost understand the code but I didn't understand the statement of b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); y(dy(k1)+1)]; what does it stand for?
what does this statement mean? I want to understand what this statement does exactly , any help? thanks alot.
does it take a row of matrix and devide it by another row matrix and the result is stored in b? I really just missunderstanding that row among others rows in the code.
all what I need is a detalied explanation what this row b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); is about ? and what it does functionality (takes two rows of matrix and devide between each other?) ?
thanks alot.

채택된 답변

Star Strider
Star Strider 2020년 12월 23일
Thank you! I recognise my code!
The assignment:
b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); y(dy(k1)+1)];
loops through the zero-crossings returned in ‘dy’ as indexed with ‘k1’ and calculates the linear regression slope and intercept terms for that small segment of the original waveform.
The next line calculates the interpolated value of the exact zero-crossing, and returns it as ‘x0’. The ‘mb’ matrix stores the slope and intercept terms.
For the record, I now use:
zci = @(v) find(diff(sign(v(:))));
since it is a bit more robust and does not have the wrap-around problems my original code for it does.
  댓글 수: 14
Star Strider
Star Strider 2020년 12월 23일
As always, my pleasure!
Star Strider
Star Strider 2021년 1월 9일
I have absolutely no idea what you are doing.
I cannot comment further.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Configure Simulation Conditions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by