how to generate loop for given program
2 次查看(过去 30 天)
显示 更早的评论
my dataset buttLoop3 is 24000x4 and i want to find out zero crossing of it...
i want to do below work in loop instead of typing it 4 time
zcd = dsp.ZeroCrossingDetector % calling function to detect zero count...
zcdOut = zcd(buttLoop3); % it counts how many times signals cross zero
y1 = buttLoop3(:,1) ; % filtered signal
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
xi1 = zci(y1); % zero crossing indices command
for k = 1:numel(xi1)-1
ti1(k) = interp1(y1([xi1(k) xi1(k)+1]), t([xi1(k) xi1(k)+1]), 0); % Interpolate To Find ‘t’ At ‘y=0 ’
end
y2 = buttLoop3(:,2) ; % filtered signal
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
xi2 = zci(y2); % zero crossing indices command
for k = 1:numel(xi2)-1
ti2(k) = interp1(y2([xi2(k) xi2(k)+1]), t([xi2(k) xi2(k)+1]), 0); % Interpolate To Find ‘t’ At ‘y=0 ’
end
y3 = buttLoop3(:,3) ; % filtered signal
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
xi3 = zci(y3); % zero crossing indices command
for k = 1:numel(xi3)-1
ti3(k) = interp1(y3([xi3(k) xi3(k)+1]), t([xi3(k) xi3(k)+1]), 0); % Interpolate To Find ‘t’ At ‘y=0 ’
end
y4 = buttLoop3(:,4) ; % filtered signal
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
xi4 = zci(y4); % zero crossing indices command
for k = 1:numel(xi4)-1
ti4(k) = interp1(y4([xi4(k) xi4(k)+1]), t([xi4(k) xi4(k)+1]), 0); % Interpolate To Find ‘t’ At ‘y=0 ’
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!