"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.058524e017.
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(S3S1);
> > > Ke=fzero('b',Ke,optimset('TolX',1e15));
> >
> > 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', 1e8);
> > 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 = valueOfFirstAtParametervalueOfSecondAtParameter
> >
> >
> > 
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com
