対数計算時のエラー

8 vues (au cours des 30 derniers jours)
夏樹 坂本
夏樹 坂本 le 17 Sep 2020
Commenté : 夏樹 坂本 le 17 Sep 2020
画像の画素値に対して対数計算を行いたいのですが下記のようなエラーメッセージが表示されます。何がいけないのでしょうか。
>> logca1 = log(ca1)
関数 'log' の呼び出し内に、不足している引数または正しくない引数データ型がないかを確認してください
  2 commentaires
stozaki
stozaki le 17 Sep 2020
坂本 様
以下のコマンドを実行した結果はどうなっておりますでしょうか?
cl = class(ca1)
stozaki
夏樹 坂本
夏樹 坂本 le 17 Sep 2020
コメントありがとうございます。
コマンドを実行したところ下記のようになりました。
cl = class(ca1)
cl =
'int16'

Connectez-vous pour commenter.

Réponse acceptée

stozaki
stozaki le 17 Sep 2020
Modifié(e) : stozaki le 17 Sep 2020
坂本様
コマンドの実行ありがとうございました。
ca1のクラスが "int16"となっています。log関数のドキュメントを見ると、入力引数のデータ型は "single" もしくは "double" となっています。従って、"int16"のデータ型は受け付けないという仕様です。
回避策としては、singleもしくはdoubleにキャストする方法は如何でしょうか?
logca1 = log(double(ca1))
どうぞ、ご検討ください。
stozaki
  1 commentaire
夏樹 坂本
夏樹 坂本 le 17 Sep 2020
データ型を変更すると動くようになりました。アドバイスありがとうございました。

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!