Clear Filters
Clear Filters

Error in ==> sym.sym>sym.double at 936 ; I want plot

1 view (last 30 days)
hello everyone ,
I want find a maximum of z but it get error like :
??? Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in ==> sym.sym>sym.double at 936
Xstr = mupadmex('symobj::double', S.s, 0);
here is my code
syms E Eg V ;
z=[ ];
y=[ ];
x=[];
for Eg=0.5:0.05:1.3;
z=[];
a = quad( '(E.^2) ./ (exp(E./0.516)-1)', Eg , 100);
for V=0:0.05:Eg;
c=3 .*(10.^8); % m/s
h=4.1361e-015; % eV.s
k=8.62E-5;
Tc=300;
Pin = 1.4458e+026 ;
g = (E.^2) ./ (exp( (E - V) ./0.0258)-1) ;
b = double(int(g,Eg,100));
P = ( 2.*V./6.3682e-027 ) .* ( a - b ) /Pin;
z=[z P];
m=max(z);
end
y = [y m];
end
Eg=0.5:0.05:1.3;
plot(Eg,y)
title('Eg=0.5~1.3');
xlabel('Eg');
ylabel('η[max]');
If set b=0 , it getting a correct result , so I think b is the problem.
y=[y m] cant saving any data .
thanks every one :)

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 16 Feb 2012
try
Eg=0.5:0.05:1.3;
V=arrayfun(@(x)0:.05:x-.05,Eg,'un',0);
Pin = 1.4458e+026 ;
a = arrayfun(@(x1)quad(@(x)x.^2./(exp(x/0.516)-1),x1,100),Eg);
y = zeros(numel(Eg),1);
for j1 = 1:numel(Eg)
b = arrayfun(@(v)quad( @(x)x.^2./(exp((x - v)/0.0258)-1),Eg(j1),100),V{j1});
y(j1) = max( 2.*V{j1}./6.3682e-027 .* ( a(j1) - b ) /Pin );
end
plot(Eg,y)
title('Eg=0.5~1.3');
xlabel('Eg');
ylabel('η[max]')
  4 Comments
Andrei Bobrov
Andrei Bobrov on 17 Feb 2012
in this case:
we create cell array 'V' with size [1xlength(Eg)], 'V' contents double arrays - vectors (eg for first cell of V: 0,.05,.1,.15.....Eg(1)-.05), please read http://www.mathworks.com/help/techdoc/ref/arrayfun.html

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!