How can i find with a simpe and easy code the zero crossing of a function?
조회 수: 1 (최근 30일)
이전 댓글 표시
Let's say that I have a sinus wave and i want to find and plot the zero crossing for that function.How can i do that, with a simple code?
댓글 수: 1
John D'Errico
2017년 10월 24일
Why not read the help for fzero? You might even find an example in there, rather than asking someone to re-write the documentation for fzero.
doc fzero
답변 (1개)
KSSV
2017년 10월 24일
t = linspace(0,2*pi,5000) ;
y = sin(t) ;
figure
hold on
plot(t,y) ;
%%get zeros
tol = 10^-3 ;
idx = abs(y-0)<=tol ;
plot(t(idx),y(idx),'*r') ;
%%using fzero
fun = @sin ;
x = fzero(fun,[0 2*pi]) ;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!