Hi.
I am trying to encode my gray scale image using encode(img,291,247,'hamming/decimal') but I get this error :
Error using encode (line 78)
For 'hamming' code with decimal data, MSG must be a vector.
If I convert it to a vector using img = img(:), I get this error
Error using *
MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar.
Error in encode (line 117)
code = rem(msg * gen, 2);
Error in dummy (line 5)
encoded = encode(img,127,120,'hamming/decimal');
Can you please help me with this?

 採用された回答

Jan
Jan 2021 年 4 月 29 日

0 投票

What is the type of the variable img? The documentation of encode() mentions, that the 1st input must by a double. So try:
encode(double(img(:)), 291, 247, 'hamming/decimal')

4 件のコメント

Neeraj Chimwal
Neeraj Chimwal 2021 年 4 月 30 日
I have been trying this for 2 days, but never thought of converting to double.
Now I feel dumb.
Anyway thankyou
Jan
Jan 2021 年 4 月 30 日
The error message is not optimal. Better:
For 'hamming' code with decimal data, MSG must be a <double> vector.
Neeraj Chimwal
Neeraj Chimwal 2021 年 4 月 30 日
Yes, the error message is not helpful for beginners
Jan
Jan 2021 年 4 月 30 日
I do agree with you. It would be useful if you write an enhancement request to TMW to fix this message. You can include a link to this question, to explain the details.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2021 年 4 月 29 日

コメント済み:

Jan
2021 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by