対数計算時のエラー

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

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!