Conversion to double from sym is not possible
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
1 commentaire
Réponse acceptée
Andrei Bobrov
le 12 Oct 2011
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 commentaires
Plus de réponses (1)
Walter Roberson
le 12 Oct 2011
Try
Dv(i) = double( -(Bc*Pin/(4*pi*10*Ein(i)))*(G(i)-1) );
0 commentaires
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!