请解释Octave-Error:运算符/:不符合参数(op1为1x1,op2为1x10) [英] Please Explain Octave-Error : operator /: nonconformant arguments (op1 is 1x1, op2 is 1x10)

查看:187
本文介绍了请解释Octave-Error:运算符/:不符合参数(op1为1x1,op2为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)');

如标题中所述,产生的错误如下: 错误:ger5:运算符/:参数不一致(op1为1x1,op2为1x10) 我做了很多测试,发现问题出在第9行的T变量: n = Nc *(e.^(-Eg/(2 * k * 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)');

在这种情况下,我只需将T替换为500,代码就可以正常运行.遗憾的是,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.

推荐答案

添加一个.*,/和^符号之前.这样可以确保八度使用标量乘法而不是矩阵乘法.

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

这篇关于请解释Octave-Error:运算符/:不符合参数(op1为1x1,op2为1x10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆