开发者

Scilab: "first and second input arguments must be real at line 53 of function histplot"

Why does this piece of code fail in Scilab?

N=1000;
U=rand(N, 1);
X=(9*U - 1)^(1/3);开发者_运维百科
histplot(200, X);


Most likely the code fails because X is not real. This can happen if U is smaller than 1/9, which means that you take the third root of a negative number.

You can find problematic values of U by checking for whether the values in X are real.


Is there a '.' per element operator missing?

X=(9*U - 1).^(1/3);

EDIT:
As Jonas points out Scilab histplot won't accept complex values as argument. MATLAB on the other hand fails because of the missing 'per element' operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜