1

I am trying to do a simple integration, I have attached the code. Could you please help me as in what am I doing wrong in the code.

function [f_value] = SurfArea ()

        a=[1.78E-05 3.39E-04 0.0104 -0.05791 -16.36];

        R = 30;

        da = polyder(a);

        syms x

        integrand = int((x*sqrt(1+1/(poly2sym(da)).^2)),-R,0);

        f_value = sym2poly(integrand);

end

I want to remove the warning, please help.

apomene
  • 14,282
  • 9
  • 46
  • 72
Sagar
  • 165
  • 1
  • 4
  • 17
  • 1
    Related: http://stackoverflow.com/questions/20082581/explicit-integral-could-not-be-found – herohuyongtao Feb 12 '14 at 15:07
  • possible duplicate of [Silencing warning messages in MATLAB](http://stackoverflow.com/questions/6651208/silencing-warning-messages-in-matlab) - though @RodyOldenhuis's answer here is more specific... – horchler Feb 12 '14 at 15:08
  • @horchler I tried using the vpa function, however I am still getting the same warning. Could you please explain the implementation of 'double' as mentioned there. I didn't get that. – Sagar Feb 12 '14 at 15:13
  • @Sagar: Using `vpa` won't suppress the warning because you still have to run `int`. The warning is telling you that the integral can't be solved symbolically. However, sometimes you can pass the output from `int` to `vpa` or `double` or `eval` and the integral will be evaluated numerically. Though you might look into adapting your equations to [`integral`](http://www.mathworks.com/help/matlab/ref/integral.html) in such cases. – horchler Feb 12 '14 at 16:35

1 Answers1

0

If you issue the command

>> [~,ID] = lastwarn

right afer the warning is issued, you'll get the relevant warning ID to use. You can use that like so:

%// Force the warning off
warnstate = warning('off', 'symbolic:sym:int:warnmsg1');

%// ... do the integration etc.

%// Switch warning back into original state
warning(warnstate);

By the way:

  • you seem to want to return a polynomial coefficient vector. How do you expect that integral to result in a polynomial?!
  • If you want numerical outcomes, take a look at integral (R2013) or quadgk (<=R2012) instead. It's a lot faster than using the symbolic toolbox.
Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96