Borrar filtros
Borrar filtros

How can I make variable value instead of constant one?

1 visualización (últimos 30 días)
sookyung Kang
sookyung Kang el 1 de Jun. de 2020
Comentada: sookyung Kang el 1 de Jun. de 2020
a = 1.27; b = 0.19 ; c = 0.44 ; d = 0.2 ; e = 300 ; f = 5*10^21 ; g = 2*10^23 ; h = 1.2 ; i = 8.61733*10^(-5); j = 2*10^21; k1 = 0.1 ; B1 = 0.045 ;
x = linspace(0, 1.7);
A1 = j.*(f/g).^((i.*e)/(4*B1)).*((2*B1.^2)/((2*B1)-(i.*e))).*exp(-(1/(2*B1)).*(a-k1-((b.^2)/(4*B1))));
D1 = (1/sqrt(2*b.^2*pi)).*exp(-(x+((b.^2)/(2*B1))-a).^2/(2*b.^2));
C1 = (2*exp((h-x)/(i.*e)))/(1+2*exp((h-x)/(i.*e))+exp(((2*h)-(2*x)-d)/(i.*e)));
E1 = A1.*((2/C1).^((i*e)/(2*B1)))*D1 ;
E1 = linspace(10^10, 10^19);
D0 = linspace(10^10, 10^19);
D0 = C1*E1;
xlabel('x'), ylabel ('y'),plot(x,D0,'r')
I should obtain parabola graph with y range from 10^10 to 10^19, but I got several 10^3 in y-axis. So I found out C1 showed constant value instead of variable figure as x ranges from 0 to 1.7.
How can I fix this problem?
  1 comentario
KALYAN ACHARJYA
KALYAN ACHARJYA el 1 de Jun. de 2020
Editada: KALYAN ACHARJYA el 1 de Jun. de 2020
C1 = ((2*exp(h-x)/(i.*e))/(1+2*exp(h-x))/(i.*e))+exp(((2*h)-(2*x)-d)/(i.*e));
The code mesh with multiple / sign, please assign to specific part with () bracket, so that it can be readable easily to dedug the code.

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 1 de Jun. de 2020
Editada: Ameer Hamza el 1 de Jun. de 2020
You need to use element-wise operators
a = 1.27; b = 0.19 ; c = 0.44 ; d = 0.2 ; e = 300 ; f = 5*10^21 ; g = 2*10^23 ; h = 1.2 ; i = 8.61733*10^(-5); j = 2*10^21; k1 = 0.1 ; B1 = 0.045 ;
x = linspace(0, 1.7);
A1 = j.*(f/g).^((i.*e)/(4*B1)).*((2*B1.^2)./((2*B1)-(i.*e))).*exp(-(1/(2*B1)).*(a-k1-((b.^2)./(4*B1))));
D1 = (1./sqrt(2*b.^2*pi)).*exp(-(x+((b.^2)./(2*B1))-a).^2./(2*b.^2));
C1 = (2*exp((h-x)./(i.*e)))./(1+2*exp((h-x)./(i.*e))+exp(((2*h)-(2*x)-d)./(i.*e)));
E1 = A1.*((2./C1).^((i.*e)./(2*B1))).*D1 ;
xlabel('Energie (eV)'), ylabel ('la densite des etats profonds (cm^-3/eV)'),plot(x,C1,'r')
Plot for C1:
  1 comentario
sookyung Kang
sookyung Kang el 1 de Jun. de 2020
Thanks a lot for your help. I've been confused to use element-wise operators like ./ and I could understand what I was wrong.

Iniciar sesión para comentar.

Más respuestas (1)

Drishti Jain
Drishti Jain el 1 de Jun. de 2020
You can use a 'for' loop.
for z=1:100
C1(z) = (2*exp((h-x(z))/(i.*e)))/(1+2*exp((h-x(z))/(i.*e))+exp(((2*h)-(2*x(z))-d)/(i.*e)));
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by