Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Making two functions equal
Date: Wed, 6 Jul 2011 10:13:10 +0000 (UTC)
Organization: IITK
Lines: 63
Message-ID: <iv1cfm$sfp$1@newscl01ah.mathworks.com>
References: <iuqiu9$mdj$1@newscl01ah.mathworks.com> <iuqojk$69r$1@newscl01ah.mathworks.com> <iuvs91$19b$1@newscl01ah.mathworks.com> <iv00l3$d2b$1@newscl01ah.mathworks.com> <iv0vj6$rlf$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1309947190 29177 172.30.248.47 (6 Jul 2011 10:13:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 6 Jul 2011 10:13:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2795384
Xref: news.mathworks.com comp.soft-sys.matlab:735081

"Reshma B" wrote in message <iv0vj6$rlf$1@newscl01ah.mathworks.com>...
> Dear Sir,
> Thank you very much for your reply.I got the values. But when I enter some values of q, I am getting an error that 

Warning: Matrix is close to singular or badly scaled.
         Results may be inaccurate. RCOND = 4.058524e-017. 

Is there any way to correct it? 
 Regards,
 Reshma

> "Steven_Lord" <slord@mathworks.com> wrote in message <iv00l3$d2b$1@newscl01ah.mathworks.com>...
> > 
> > 
> > "Reshma B" <rbmindworking@gmail.com> wrote in message 
> > news:iuvs91$19b$1@newscl01ah.mathworks.com...
> > > Dear Sir,
> > >
> > > Thank you very much for your reply. I tried to solve the problem using 
> > > fzero. I am not familiar with using fzero. Could you please tell me the 
> > > problem?
> > > q=input('Enter q');
> > > Ke=0.01;
> > > S3=r_nl_3layers_noG_equi_fn_noinput(q);
> > > S1 = r_nonlinear_1layer_noG_equi_fn_noinput(q,Ke); b = abs(S3-S1); 
> > > Ke=fzero('b',Ke,optimset('TolX',1e-15));
> > 
> > Create a function that accepts an input, evaluates your two functions for 
> > that input, and returns their difference. Then call FZERO on _that_ 
> > function.
> > 
> > 
> > % Begin subtractTheTwoFunctions.m
> > function thedifference = subtractTheTwoFunctions(q, Ke)
> > valueOfFirstFunction = r_nl_3layers_noG_equi_fn_noinput(q);
> > valueOfSecondFunction = r_nonlinear_1layer_noG_equi_fn_noinput(q,Ke);
> > thedifference = valueOfFirstFunction -valueOfSecondFunction;
> > % End subtractTheTwoFunctions.m
> > 
> > 
> > % Paste the following into the Command Window once you've created the 
> > function above
> > Ke = 0.01;
> > initialGuess = 0.5;
> > options = optimset('TolX', 1e-8);
> > parameterValue = fzero(@(p) subtractTheTwoFunctions(p, Ke), initialGuess, 
> > options);
> > 
> > % To check, compute the value of each function for the parameterValue 
> > returned by FZERO:
> > valueOfFirstAtParameter = r_nl_3layers_noG_equi_fn_noinput(parameterValue);
> > valueOfSecondAtParameter = 
> > r_nonlinear_1layer_noG_equi_fn_noinput(parameterValue, 0.01);
> > 
> > % Now subtract the function values. The difference should be small.
> > differenceAtParameter = valueOfFirstAtParameter-valueOfSecondAtParameter
> > 
> > 
> > -- 
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on 
> > http://www.mathworks.com