2016-08-16 114 views
1

如果我要画一个sin(x)图使用八度,我会做绘图错误“内存耗尽或请求的大小太大”

x = -6:0.1:6; 
plot (x, sin(x)); 

和工作原理。

我想画一个双曲线函数,所以我尝试

x = -6:0.1:6; 
plot (x, 1/(1+exp(-x))); 

但是这给了我

error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt 

我试着用x = -4:0.2:4;,这一次得到了

error: invalid conversion of NDArray to Matrix 
error: evaluating argument list element number 2 

什么问题?

+0

尝试'plot(x,1 ./(1 + exp(-x)));' –

+0

嗯。有用。重点是什么?使用实数1(1)?哦,我现在看到明智的分工。 –

回答

1

问题出在​​。 MATLAB抛出的错误是:

Error using/
Matrix dimensions must agree. 

Carandraug's comment

倍频失败:

operator /: nonconformant arguments (op1 is 1x1, op2 is 1x121) 

你想要的是elementwise division(注意点):

x = -6:0.1:6; 
plot (x, 1./(1+exp(-x))); 

enter image description here

+0

我看到元素明智的点运算符只有当可以混淆时才需要。 (如分割,乘法......)。谢谢。 –

+1

@ChanKim'+','exp','sin'等已经执行元素明智的(检查他们的文档)。 '/'和'*'通常作为*矩阵运算符*,所以你必须明确地告诉它明智的选择,即在它们之前放一个点。 – Adriaan

+2

实际上,Octave也不能通过'operator /:nonconformant arguments(op1是1x1,op2是1x121)'进行该操作,并且不会广播。 OP错误可能来自其他地方,无法在Octave中使用他的代码进行复制(我尝试过使用Octave 3.8,4.0和未发布的4.1)。 – carandraug

相关问题