- Simulink library implementation of the behavioral model of Schmitt trigger: https://www.mathworks.com/help/sps/ref/schmitttrigger.html
- https://www.mathworks.com/matlabcentral/fileexchange/44419-schmitt-trigger
- https://www.mathworks.com/matlabcentral/fileexchange/56764-schmitt-trigger?s_tid=prof_contriblnk
Create an index based Schmitt Trigger
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello, I have a function that mimics a Schmitt Trigger to translate an analog sine wave into a digital square wave. So far, I have accomplished this with a for loop and the function works as planned. However, since I have a significant amount of data to process, I would like to do this index based for speed. I cannot think of a way to make this index based so the function performes faster.
My function is below, any suggestions on how to make this index based? Is it possible?
Thanks.
function [y] = Schmitt_Trigger(x,tL,tH)
%x is the input array that contains the analog sine wave to process.
%tL is the lower bound of the hysteresis and tH is the upper bound.
N = length(x);
y = zeros(1,N);
for i = 2:N
y(i) = y(i-1);
if y(i-1) == 0 && x(i)>tH
y(i) = 1;
end
if y(i-1) == 1 && x(i)<tL
y(i) = 0;
end
end
end
댓글 수: 0
답변 (1개)
Yash
2025년 7월 20일
편집: Yash
2025년 7월 20일
Check out these implementations of Schmitt Trigger:
In your implementation, if the crossings are well separated and the input isn't nosiy, you can use a logical mask and the function "find" to get the crossing points and reconstruct the output.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!