What does the error message "input must be real and full" mean?

6 ビュー (過去 30 日間)
Rudolf Fruehwirth
Rudolf Fruehwirth 2024 年 2 月 10 日
移動済み: Stephen23 2024 年 2 月 10 日
When I try to compute gamma(i) I get the error message "Input must be real and full." I understand that the input is not real, but what is a full input? If I call gamma with an empty argument I get an empty output. So what is the exact meaning of this error message?

採用された回答

John D'Errico
John D'Errico 2024 年 2 月 10 日
編集済み: John D'Errico 2024 年 2 月 10 日
The gamma function requires a real input. Although I recall that the symbolic version of gamma can handle complex input. But the gamma function for double precision arguments does not extend to the complex plane.
gamma(str2sym('1+i'))
ans =
gamma(1 + 1i)
vpa(ans)
ans =
0.4980156681183560427136911174622 - 0.15494982830181068512495513048389i
gamma(1+i)
Error using gamma
Input must be real and full.
Why does the error message include the full clause?
A = magic(3)
A = 3×3
8 1 6 3 5 7 4 9 2
On the full side of that message... As you cam see, A is a full matrix.
gamma(A)
ans = 3×3
5040 1 120 2 24 720 6 40320 1
gamma(sparse(A))
Error using gamma
Input must be real and full.
But sparse(A) is sparse, so not full.
And this explains both sides of that error message, since gamma does not apply to sparse matrices. It makes no sense for a sparse matrix, since gamma(0) is undefined. gamma(0) returns inf.
  1 件のコメント
Rudolf Fruehwirth
Rudolf Fruehwirth 2024 年 2 月 10 日
移動済み: Stephen23 2024 年 2 月 10 日
Many thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGamma Functions についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by