0

When I use the integral command I get the following error, even though I defined all of the variables:

Error using integralCalc/finalInputChecks
Input function must return 'double' or 'single' values. Found 'sym'.

Error in integralCalc/iterateScalarValued (line 315)
                finalInputChecks(x,fx);
.
.
.
Error in int (line 24)
f4 = (1/(t-s^4))*(rho_w_ad+t_w_ad*((x/(t-s))^2-0.5))*exp(-(x/(t-s))^2);

where rho_w_ad, t_w_ad:

syms t s x
alpha = 20;
h = 1;
rho_in = 0;
T_in = exp(-alpha*(s-h));

% This is the first integral
f1 = s*(rho_in*((s^2)/(t^2)-5)+T_in*((s^4)/(t^4)-(11*(s^2))/(2*(t^2))+3.5))*(exp(-s^2/t^2));
firstFunc = matlabFunction(f1);
rho_w_ad = @(t) integral(@(s) firstFunc(s,t) , 0,inf)*(1./t.^2.*(-1./2));

% This is the second integral
f2 = s*(rho_in*((s^2)/(t^2)-1)+T_in*((s^4)/(t^4)-(3*(s^2))/(2*(t^2))+1.5))*(exp(-s^2/t^2));
secondFunc = matlabFunction(f2);
t_w_ad= @(t) integral(@(s) secondFunc(s,t) , 0,inf)*(1./t.^2);
% f4 is further down

what am I doing wrong?

Amitai
  • 21
  • 5
  • 3
    well, the function `integral` is for numerical integration, as the documentation says: https://uk.mathworks.com/help/matlab/ref/integral.html . Symbols are not numbers. Consider using the correct function `int` :https://uk.mathworks.com/help/symbolic/sym.int.html – Ander Biguri Nov 15 '22 at 14:04

0 Answers0