how can i convert decimal to hex or another basis without use dec2hex ?

3 ビュー (過去 30 日間)
Mohammad Imam Malik
Mohammad Imam Malik 2017 年 5 月 26 日
I need to make a function about convert basis to another (decimal to oktal or another) but i dont know the prinsip , i hope some one give me tips for that

採用された回答

Jan
Jan 2017 年 5 月 26 日
I really do like this forum. But sometimes I suggest to take the time to search in the net. You can imagine, that this problem has been solved by others already. You find the general algorithm at WikiPedia and most likely your textbook for maths. When you search for "Matlab convert hex to base" you will even find running Matlab code.
  2 件のコメント
Mohammad Imam Malik
Mohammad Imam Malik 2017 年 5 月 26 日
Oke, sorry i am beginner in matlab hehe
Jan
Jan 2017 年 5 月 26 日
This is okay. Questions of beginners are welcome in this forum. Specific question get specific answers usually.

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

その他の回答 (1 件)

MathReallyWorks
MathReallyWorks 2017 年 5 月 26 日
Hello Mohammad Imam Malik,
I guess you are asking for the principle behind these conversions.
Read this:
Steps:(Decimal to hex)
1. Divide the decimal number by 16. Treat the division as an integer division.
2. Write down the remainder (in hexadecimal).
3. Divide the result again by 16. Treat the division as an integer division.
4. Repeat step 2 and 3 until result is 0.
5. The hex value is the digit sequence of the remainders from the last to first.
Check out this link for other conversion algorithm: Decimal Number Conversion
  3 件のコメント
Stephen23
Stephen23 2017 年 5 月 26 日
編集済み: Stephen23 2017 年 5 月 26 日
Use a string (1xN char) to store the values. Either generate the string using their character codes, or select the characters from a vector using indexing, or simply call sprintf with one of the hex formats.
Mohammad Imam Malik
Mohammad Imam Malik 2017 年 5 月 26 日
how? can u give me exp?

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

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by