Input function must return 'double' or 'single' values. Found 'sym'.

조회 수: 1 (최근 30일)
Amitai Sela
Amitai Sela 2022년 11월 15일
편집: Torsten 2022년 11월 15일
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?

채택된 답변

Torsten
Torsten 2022년 11월 15일
편집: Torsten 2022년 11월 15일
rho_w_ad and t_w_ad are functions of t. So you will have to define
f4 = @(t,x,s) (1./(t-s.^4)).*(rho_w_ad(t)+t_w_ad(t).*((x./(t-s)).^2-0.5)).*exp(-(x./(t-s)).^2);

추가 답변 (1개)

Marcel
Marcel 2022년 11월 15일
편집: Marcel 2022년 11월 15일
Have you tried double(yourVarHere) ?
This way you can convert your variable to the expected double and you could try if this fixes your issue. You have to convert the correct variable tho

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by