Conversion to double from sym is not possible

Hi every body,
this is my code
syms t
x=-3:.1:3;
for i=1:length(x);
Pin=3*exp(-t^2);
z=x(i);
Eo(i)=int(Pin,t,-inf,z);
Ein(i)=int(Pin,t,-inf,inf);
E(i)=Eo(i)/Ein(i);
Go=1000;
G(i)=Go/(Go-(Go-1)*exp(-E(i)*0.1));
Bc=3;
Dv(i)=-(Bc*Pin/(4*pi*10*Ein(i)))*(G(i)-1);
end
plot(x,Dv,'-r*')
when I come to plot, I get this message
Conversion to double from sym is not possible
help me please, have a nice life

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 10월 12일

0 개 추천

variant with use Symbolic Toolbox ( MATLAB R2010a )
x = -3:.1:3;
syms t
Ein = int(3*exp(-t^2),-inf,inf);
Eo0 = int(3*exp(-t^2),-inf,x(1));
E = (Eo0 + int(3*exp(-t^2),t,x(1),t))/Ein;
Dv = matlabFunction(eval((9*exp(-t^2)/(40*pi*Ein))*(1000/(1000-999*exp(-E*0.1))-1)));
plot(x,Dv(x),'-r*')
varint numeric
x = -3:.1:3;
f = @(z)3*exp(-z.^2);
Ein = quadgk(f,-inf,inf);
Eo0 = quadgk(f,-inf,x(1));
Dv1 = arrayfun(@(x)quadgk(f,-inf,x),x);
Dv = (3*f(x)/(40*pi*Ein)).*(1000./(1000-999*exp(-(Eo0+Dv1)/Ein*0.1))-1);
plot(x,Dv,'k-+')

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 10월 12일

0 개 추천

Try
Dv(i) = double( -(Bc*Pin/(4*pi*10*Ein(i)))*(G(i)-1) );

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by