How can it be possible the following calculation have negative values?

1 回表示 (過去 30 日間)
Dimitrios
Dimitrios 2014 年 10 月 2 日
コメント済み: John D'Errico 2014 年 10 月 2 日
I am using the followind code :
Output = bsxfun(@rdivide,(x*y'),z).*sqrt(k+n);
size(x) = 1x1
size(y) = 1x50
size(z) = 50x36
size(k) = 50x36
size(n) = 50x36
All values in the matrices are positive. I cant figure out why 2 values get negative in the output.How could it be possible?
  2 件のコメント
dpb
dpb 2014 年 10 月 2 日
編集済み: dpb 2014 年 10 月 2 日
well, just to make sure let's see
all(y>0)
all(z(:)>0)
etc., ...
John D'Errico
John D'Errico 2014 年 10 月 2 日
You say the numbers are positive, but are they real numbers though? For example...
(1+sqrt(-1)) > 0
ans =
1
When matlab does a compare with complex args here, it tests the real part, so it thinks that 1 + i is greater than 0.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by