|
"Semih " <gereksizbirsuruseyicin@gmail.com> wrote in message <g7eus8$8a4$1@fred.mathworks.com>...
> Thank you very much for the solution. Now it works well !!!
>
> "Steven Lord" <slord@mathworks.com> wrote in message
> <g7er81$olm$1@fred.mathworks.com>...
> >
> > "Semih " <gereksizbirsuruseyicin@gmail.com> wrote in message
> > news:g7edrv$c51$1@fred.mathworks.com...
> > > Hello! I want to compute the following equation numerically
> > > from 0 to 1 and I tried it with "quad" command. Then I took
> > > an error which says "it must have an feval method" which I
> > > can not understand. If I try with "int" command it gives
> > > elliptic functions. Can you advice any other method to
> > > perform this numerical integral operation?
> > >
> > > I=sqrt((1-x^2)/(((1-rho)^-1)-x^2)) with taking rho=0.8
> >
> > QUAD expects the integrand to be a function handle. From
> the fact that you
> > mentioned this works with INT, I suspect that I is a sym
> object. If you
> > want to obtain a double precision value from INT, specify
> limits of
> > integration and use the DOUBLE function -- if you want a
> "sym object that is
> > a number" use VPA.
> >
> >
> > syms x
> > rho = 0.8;
> > I=sqrt((1-x^2)/(((1-rho)^-1)-x^2));
> > value = int(I, x, 0, 1)
> > doubleValue = double(value) % This is the double
> representation of value
> > vpaValue = vpa(value) % This is value calculated to some
> number of decimal
> > places
> >
> >
> > If instead you wanted to use QUAD, you would need to use a
> function handle:
> >
> >
> > rho = 0.8;
> > % I'm assuming you're using MATLAB 7.0 (R14) or later, and
> so have access to
> > anonymous functions
> > % If not, see Q4.13 in the newsgroup FAQ:
> > % http://matlabwiki.mathworks.com/MATLAB_FAQ
> > % for how to pass rho into your integrand function
> > If= @(x) sqrt((1-x.^2)./(((1-rho)^-1)-x.^2));
> > value2 = quad(If, 0, 1)
> >
> >
> > Note value2, doubleValue, and vpaValue will not be
> identical -- QUAD
> > calculates the integral to within a tolerance, while value
> (from which
> > doubleValue and vpaValue are calculated) is computed
> exactly symbolically.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> >
> >
>
|