简体   繁体   English

请说明Octave-Error:运算符/:不符合参数(op1为1x1,op2为1x10)

[英]Please Explain Octave-Error : operator /: nonconformant arguments (op1 is 1x1, op2 is 1x10)

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))); 如标题中所述,产生的错误如下: 错误:ger5:运算符/:参数不一致(op1为1x1,op2为1x10)我做了很多测试,并且我认为问题出在第9行的T变量: 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. 在这种情况下,我只需将T替换为500,代码就可以正常运行。 Sadly T, can not be replaced by a certain number since it is the variable used in my graph. 遗憾的是,T不能用某个数字代替,因为它是我的图形中使用的变量。 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. 谢谢。

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)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM