×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

zero crossing

zero crossing

zero crossing

(OP)
How do I compute the zero crossing of one function given two values. Ex a value where zero crossing occurs for
sin(x) where 7<x>6?

RE: zero crossing

Hi,
This is a simple solution for you:
--------------------------------------------------
function [x0,XTOL]=zercros(F,LLIM,ULIM,XTOL,YTOL)
TOL=(ULIM-LLIM)*XTOL;
n=0;
J=[];
while isempty(J) & n<100
x=linspace(LLIM,ULIM,round(1/TOL));
y=eval([F '(x)']);
ay=abs(y);  % absolute value
J=find(ay<YTOL);
TOL=TOL/2;
n=n+1;
end
dy=diff(y); % derivative
J1=find(dy(J)); % nonzero derivatives at detected points
x0=x(J(J1));
XTOL=TOL/((ULIM-LLIM);
______________________________
Note that this method may give you less zero crossings than exists because it designed to find at least one or give up after 100 iterations. If you find that XTOL have changed, you better run it again with a twice value of the resulted XTOL to find if there are other solutions in the region.
Usually you will get for each zero crossing to values of x0, one just before and the second just after it.

Joe
BSTEX - Equation viewer for Matlab
http://www.geocities.com/bstex2001

RE: zero crossing

(OP)
Thanks for the help, it was very usefull.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources