Info

This question is closed. Reopen it to edit or answer.

Please help with following code i am new with matlab and don't understand the error

1 view (last 30 days)
clear
Eg = input('Enter your value for Eg(T) = ');
x = input('Enter your lower range for T = ');
y = input('Enter your higher range for T = ');
kb = 1.38*10^-23;
h = 6.63*10^-34;
T = x:10:y;
me = 6.19*10^-32;
mh = 5.10*10^-31;
k = (2*(((2*pi*kb*T)/(h^2))^1.5)*((me*mh)^3/4))
ni = k*exp((-Eg/2*kb*T))
plot(ni,T);
xlabel('Ni');
ylabel('Temperature');
display(ni);
  1 Comment
raviraja
raviraja on 30 Oct 2014
Edited: raviraja on 30 Oct 2014
First tell about the program , like.. for which you have written the code
then select proper tags... then someone can be able to help.. :)

Answers (2)

Torsten
Torsten on 30 Oct 2014
Try
k = 2*(2*pi*kb*T/h^2).^1.5*(me*mh)^3/4
instead of
k = (2*(((2*pi*kb*T)/(h^2))^1.5)*((me*mh)^3/4))
Best wishes
Torsten.

MA
MA on 30 Oct 2014
clear all
clc;
Eg = input('Enter your value for Eg(T) = ');
x = input('Enter your lower range for T = ');
y = input('Enter your higher range for T = ');
kb = 1.38*10^-23;
h = 6.63*10^-34;
T = x:10:y;
me = 6.19*10^-32;
mh = 5.10*10^-31;
k=zeros(1,length(T));
ni=zeros(1,length(T));
for i=1:length(T)
k(i)=2*(((2*pi*kb*T(i))/(h^2))^1.5)*(((me*mh)^3)/4);
ni(i)=k(i)*exp(-Eg/(2*kb*T(i)));
end
plot(ni,T)
xlabel('Ni')
ylabel('Temperature')

This question is closed.

Community Treasure Hunt

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

Start Hunting!