2

I have an issue running a certain script in octave. This is the code that produces the error:

#germanium
T=410:20:600;
x=linspace(400,410,100);
y=linspace(10^9,10^9,100);
k=8.5*10 .^(-5);
Eg=0.59;
Nc300=1.02*10^13;
Nc=Nc300*((T/300).^(3/2));
n=Nc*(e.^(-Eg/(2*k*T)));
plot(T,n,x,y,'m');
grid on
xlabel('Temprature');
ylabel('Electron Density n');
title('Germanium n(T)');

As mentioned in the Title, the error that is produced is the following: error: ger5: operator /: nonconformant arguments (op1 is 1x1, op2 is 1x10) I have done a lot of testing, and I figured that the problem originates from the T variable on the 9th line : n=Nc*(e.^(-Eg/(2*k*T))); The codes run fine without it. For example :

#germanium
T=410:20:600;
x=linspace(400,410,100);
y=linspace(10^9,10^9,100);
k=8.5*10 .^(-5);
Eg=0.59;
Nc300=1.02*10^13;
Nc=Nc300*((T/300).^(3/2));
n=Nc*(e.^(-Eg/(2*k*500)));
plot(T,n,x,y,'m');
grid on
xlabel('Temprature');
ylabel('Electron Density n');
title('Germanium n(T)');

In which case I simply replaced T with 500 , the code runs perfectly fine. Sadly T, can not be replaced by a certain number since it is the variable used in my graph. Although I did some digging, I never managed to fully understand this error, or how to fix it, thus any help would be greatly appreciated. Thanks.

1 Answer 1

7

Add a . before your *, /, and ^ signs. This will ensure that octave uses scalar multiplication instead of matrix multiplication.

n=Nc.*(e.^(-Eg./(2.*k.*T)));
3
  • Oh, I swear I tried that already... Thanks a lot for the response, my issue is solved. :) Commented Jun 25, 2019 at 18:28
  • @ForeverTinkering Please let us know what the solution was so others that have the same problem can benefit from your experience. Commented Jun 9, 2020 at 10:57
  • @Silver can you please answer this. idk what is wrong here. stackoverflow.com/questions/63666436/… Commented Sep 1, 2020 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.