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
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
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]) ;

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by