Conversion to double from sym is not possible
1 次查看(过去 30 天)
显示 更早的评论
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
2011-10-12
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-+')
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!