Error while using dec2bin() : too many input arguments

when i run this code:
M = 'Hello';
% Now encode:
Mbinlong = reshape(dec2bin(double(M),7).',[],1)
I get this error :
Error using dec2bin Too many input arguments.
why this happens? How can i resolve this error?

8 件のコメント

Walter Roberson
Walter Roberson 2017 年 2 月 22 日
The code works as-is for me. Which MATLAB version are you using?
Jan
Jan 2017 年 2 月 22 日
Please post the complete error message. I assume that another line is affected.
Walter Roberson
Walter Roberson 2017 年 2 月 22 日
Please show
which -all dec2bin
in case you are getting a different dec2bin than is expected
ANJANA KRISHNAN A
ANJANA KRISHNAN A 2017 年 2 月 27 日
i'm using MATLAB R2013a version
ANJANA KRISHNAN A
ANJANA KRISHNAN A 2017 年 2 月 27 日
when i use the same code without including the argument '7',the code actually works!
Mbinlong = reshape(dec2bin(double(M)).',[],1);
But it represents that text in binary using 65535 bits.why so? can i represent it with lesser number of bits?
Walter Roberson
Walter Roberson 2017 年 2 月 27 日
Please show the output of
which -all dec2bin
R2013a did support passing the number of bits; see http://www.mathworks.com/help/releases/R2013a/matlab/ref/dec2bin.html
I think you are getting someone else's dec2bin
ANJANA KRISHNAN A
ANJANA KRISHNAN A 2017 年 2 月 27 日
編集済み: ANJANA KRISHNAN A 2017 年 2 月 27 日
output of which -all dec2bin is :
F:\MATLAB\RSA\dec2bin.m
C:\Program Files\MATLAB\R2013a\toolbox\matlab\strfun\dec2bin.m % Shadowed
ANJANA KRISHNAN A
ANJANA KRISHNAN A 2017 年 2 月 27 日
Thank you sir!! I think i was getting the dec2bin of the folder RSA!!Now i renamed that script.it's ok,right??

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

 採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 27 日

0 投票

You need to remove F:\MATLAB\RSA
from your MATLAB path. You can do that using pathtool

1 件のコメント

ANJANA KRISHNAN A
ANJANA KRISHNAN A 2017 年 2 月 27 日
it works!
the output is a 35x1 char.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by