Converting a String to Double without str2double

So I have to write a Programm that converts a binary code into a dezimal number.
The problem is that we insert the binary code in form of a string and I'm not supposed to use the str2double command to convert the string.

 採用された回答

Geoff Hayes
Geoff Hayes 2020 年 12 月 10 日

1 投票

Sanjin - why do you need to convert it using str2double?
check=z(k);
In the above check is a character so you could compare it to '0' or '1'. If neither of these characters, then it is invalid.

1 件のコメント

Sanjin Spahic
Sanjin Spahic 2020 年 12 月 10 日
Thank you never thought about to just check if its '0'or '1' like this.
I'm new to pragramming tanks for the help mate.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2020 年 12 月 10 日

編集済み:

2020 年 12 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by