Question

I wish to perform an integration as indicated below.

I am facing an error because the I am using the integration variable 'u' inside interpolation function. (If I replace 'u' inside interpolation function by some constant, the integration runs fine.)

>>syms u
>>double(int(2*interp1(x,y,u),u,0,0.1))
   Error using interp1>Interp1D (line 330)
   Inputs must be floats, namely single or double.
    Error in interp1 (line 220)
    Vq = Interp1D(X,V,Xq,method);

Can you please provide some pointers to fix it.

P.S.: For clarification, y=f(x) [piecewise function] which is why I am interpolating to determine intermediate values.

Thanks a lot !!

Était-ce utile?

La solution

You should replace int by a simpler integration routine, and forget about syms. Try the build-in integrate, or https://ece.uwaterloo.ca/~dwharder/NumericalAnalysis/13Integration/romberg/matlab.html

Alternatively, you may find an alternative to interp1, and call int on each of its subintervals.

Autres conseils

Thanks folks for help, I figured out that integral() fixes the issue instead of symbolic integ. Thanks a lot !!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top