×
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

Intersecting functions
2

Intersecting functions

Intersecting functions

(OP)
Hi everyone,

I need to know how to find the intersection of two functions. They are both quite complex (no polynomials), but only dependent on one variable. So the goal is to find the value of this variable for which the two functions are equal.
It's part of a simulation, so it should be fast and efficient as well.

Does anybody have a suggestion or know where I could find more info?

Sorry if this is a stupid question, I'm only just starting to learn Matlab.

Thanks,
Sam

RE: Intersecting functions

If your two functins are f(x) and g(x) then all you need to do is find the roots of (f(x)-g(x))

I don't have matlab on this machine, so i can't tell you how to do that, but you are basically looking for a Newton-Raphson approach.

http://dmpeli.math.mcmaster.ca/Matlab/Math1J03/LectureNotes/Lecture4_4.htm

for an example (the second one down)

Cheers

Greg Locock

RE: Intersecting functions

Hi,
Use fzero for the functions difference F=f1-f2.
help fzero
 FZERO  Scalar nonlinear zero finding.
    X = FZERO(FUN,X0) tries to find a zero of the function FUN near X0.


Joe Sababa

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

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

RE: Intersecting functions

(OP)
Thanks a lot!

Fzero seems like the right solution for my problem, however I'm having some trouble getting it to work.
I would like to define my functions in the m-file I need them in. I believe I have to use a function handle for this (@) but this doesn't work for different reasons.

Here's my problem:

a1         = ((-16/gamma)*(q/omega) + (8/3)*mu*theta0 - 2*mu*(lambdac+lambdai))/(1-0.5*mu^2);
CTelement  =  Clalpha*(sigma/4)*((2/3)*theta0*(1+(3/2)*mu^2) - (lambdac+lambdai));
CTGlauert  =  2*lambdai*sqrt(((V/(omega*R))*cos(alphac-a1))^2 + ((V/(omega*R))*sin(alphac-a1)+lambdai)^2);
F          =  CTelement - CTGlauert;

lambdai0   = 0.05;
lambdai    = fzero(F,lambdai0)

lambdai is the variable in functions a1, CTelement and CTGlauert. All other parameters are constants. The goal is to find lambdai for which F becomes zero.

How do I define these functions properly and use the fzero command on them?
The way it is stated here, Matlab doesn't know what to do with lambdai in the functions a1. When I fill everything in into the F function (rather unelegant) Matlab doesn't know what the constants are despite that I defined them before in the m-file.

Any help appreciated! Again thanks in advance.

Kind regards,
Sam

RE: Intersecting functions

These equations seem familiar, my guess is that you are iterating on the inflow for a rotor thrust calculation, possibly for a trim condition.  I believe you may be posing the problem incorrectly.  Typically, the derivate is analytically derived, and newton iteration is used to iterate on inflow coefficient.  However, the following code does solve the equations as you posed them.  

Good Luck
John

function junk

global gamma q omega mu theta0 lambdac Clalpha sigma V R alphac
gamma = 1.08;
q=24;
omega=600/19;
mu=0.2;
theta0=8*pi/180;
lambdac=0;
Clalpha=5.1;
sigma=(2*19*3)/(pi*19^2);
V=20/600;
R=19;
alphac=0;

lambdai0   = 0.05;
lambdai    = fzero(@my_F,lambdai0)

function F=my_F(lambdai)

global gamma q omega mu theta0 lambdac Clalpha sigma V R alphac
a1         = ((-16/gamma)*(q/omega) + (8/3)*mu*theta0 - 2*mu*(lambdac+lambdai))/(1-0.5*mu^2);
CTelement  = Clalpha*(sigma/4)*((2/3)*theta0*(1+(3/2)*mu^2) - (lambdac+lambdai));
CTGlauert  = 2*lambdai*sqrt(((V/(omega*R))*cos(alphac-a1))^2 + ((V/(omega*R))*sin(alphac-a1)+lambdai)^2);
F          = CTelement - CTGlauert;

RE: Intersecting functions

I did a quick look for information on iterating on inflow for a rotor model, and found this paper.  It has some detail on the inflow calculation.

http://www.ccit.edu.tw/~jccit/pdf/32-1/p17.pdf

Good luck on your simulation.

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