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

查看:28
本文介绍了请解释 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)');

如标题中所述,产生的错误如下:错误: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 : operator/: nonconformant arguments (op1 is 1x1, op2 is 1x10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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