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
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
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
for an example (the second one down)
Cheers
Greg Locock
RE: Intersecting functions
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
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
Any help appreciated! Again thanks in advance.
Kind regards,
Sam
RE: Intersecting functions
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
http://www.ccit.edu.tw/~jccit/pdf/32-1/p17.pdf
Good luck on your simulation.