{"id":44784,"date":"2025-06-30T18:59:34","date_gmt":"2025-06-30T18:59:34","guid":{"rendered":"https:\/\/gaviki.com\/blog\/?p=44784"},"modified":"2025-06-30T18:59:35","modified_gmt":"2025-06-30T18:59:35","slug":"number-conversion-using-matlab-between-binary-and-decimal","status":"publish","type":"post","link":"https:\/\/gaviki.com\/blog\/number-conversion-using-matlab-between-binary-and-decimal\/","title":{"rendered":"Number conversion using MATLAB between binary and decimal."},"content":{"rendered":"\n<p>Number conversion using MATLAB between binary and decimal. Show the working steps. 1) Convert the binary number 1010001 into decimal. 2) Convert the decimal number 145 into binary. Number conversion using MATLAB between hexadecimal and decimal. Show the working steps. 1) Convert the hexadecimal number B4E3 into decimal. 2) Convert the decimal number 52705 into hexadecimal.<\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">The Correct Answer and Explanation is:<\/mark><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Binary to Decimal Conversion (MATLAB Example)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1) Convert the binary number <code>1010001<\/code> into decimal:<\/strong><\/h4>\n\n\n\n<p>To convert a binary number to decimal, we need to multiply each bit of the binary number by 2 raised to the power of its position (starting from 0 on the right).<\/p>\n\n\n\n<p><strong>Step-by-step breakdown:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start with the binary number: <code>1010001<\/code>.<\/li>\n\n\n\n<li>The rightmost digit (1) is at position 0: 1\u00d720=11 \\times 2^0 = 11\u00d720=1.<\/li>\n\n\n\n<li>The next digit (0) is at position 1: 0\u00d721=00 \\times 2^1 = 00\u00d721=0.<\/li>\n\n\n\n<li>The next digit (0) is at position 2: 0\u00d722=00 \\times 2^2 = 00\u00d722=0.<\/li>\n\n\n\n<li>The next digit (0) is at position 3: 0\u00d723=00 \\times 2^3 = 00\u00d723=0.<\/li>\n\n\n\n<li>The next digit (1) is at position 4: 1\u00d724=161 \\times 2^4 = 161\u00d724=16.<\/li>\n\n\n\n<li>The next digit (0) is at position 5: 0\u00d725=00 \\times 2^5 = 00\u00d725=0.<\/li>\n\n\n\n<li>The next digit (1) is at position 6: 1\u00d726=641 \\times 2^6 = 641\u00d726=64.<\/li>\n<\/ol>\n\n\n\n<p>Now, sum the results: 64+0+16+0+0+0+1=8164 + 0 + 16 + 0 + 0 + 0 + 1 = 8164+0+16+0+0+0+1=81.<\/p>\n\n\n\n<p>Thus, <code>1010001<\/code> in binary is equivalent to <strong>81<\/strong> in decimal.<\/p>\n\n\n\n<p><strong>MATLAB code for binary to decimal conversion:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matlabCopyEdit<code>binary_number = '1010001';\ndecimal_value = bin2dec(binary_number);\ndisp(decimal_value);  % Output will be 81\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Decimal to Binary Conversion (MATLAB Example)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2) Convert the decimal number <code>145<\/code> into binary:<\/strong><\/h4>\n\n\n\n<p>To convert a decimal number to binary, repeatedly divide the number by 2, noting down the remainders.<\/p>\n\n\n\n<p><strong>Step-by-step breakdown:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Divide 145 by 2: quotient = 72, remainder = 1.<\/li>\n\n\n\n<li>Divide 72 by 2: quotient = 36, remainder = 0.<\/li>\n\n\n\n<li>Divide 36 by 2: quotient = 18, remainder = 0.<\/li>\n\n\n\n<li>Divide 18 by 2: quotient = 9, remainder = 0.<\/li>\n\n\n\n<li>Divide 9 by 2: quotient = 4, remainder = 1.<\/li>\n\n\n\n<li>Divide 4 by 2: quotient = 2, remainder = 0.<\/li>\n\n\n\n<li>Divide 2 by 2: quotient = 1, remainder = 0.<\/li>\n\n\n\n<li>Divide 1 by 2: quotient = 0, remainder = 1.<\/li>\n<\/ol>\n\n\n\n<p>Reading the remainders from bottom to top gives the binary representation: <strong>10010001<\/strong>.<\/p>\n\n\n\n<p><strong>MATLAB code for decimal to binary conversion:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matlabCopyEdit<code>decimal_number = 145;\nbinary_value = dec2bin(decimal_number);\ndisp(binary_value);  % Output will be '10010001'\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Hexadecimal to Decimal Conversion (MATLAB Example)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1) Convert the hexadecimal number <code>B4E3<\/code> into decimal:<\/strong><\/h4>\n\n\n\n<p>Hexadecimal uses base 16, and each digit represents a power of 16. The conversion process is as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Write the hexadecimal number: <code>B4E3<\/code>.<\/li>\n\n\n\n<li>The hexadecimal digits are: B = 11, 4 = 4, E = 14, 3 = 3.<\/li>\n\n\n\n<li>Each digit corresponds to a power of 16 starting from the rightmost position:\n<ul class=\"wp-block-list\">\n<li>11\u00d7163=11\u00d74096=4505611 \\times 16^3 = 11 \\times 4096 = 4505611\u00d7163=11\u00d74096=45056<\/li>\n\n\n\n<li>4\u00d7162=4\u00d7256=10244 \\times 16^2 = 4 \\times 256 = 10244\u00d7162=4\u00d7256=1024<\/li>\n\n\n\n<li>14\u00d7161=14\u00d716=22414 \\times 16^1 = 14 \\times 16 = 22414\u00d7161=14\u00d716=224<\/li>\n\n\n\n<li>3\u00d7160=3\u00d71=33 \\times 16^0 = 3 \\times 1 = 33\u00d7160=3\u00d71=3<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Summing these values gives: 45056+1024+224+3=4630745056 + 1024 + 224 + 3 = 4630745056+1024+224+3=46307.<\/p>\n\n\n\n<p>Thus, <code>B4E3<\/code> in hexadecimal is equivalent to <strong>46307<\/strong> in decimal.<\/p>\n\n\n\n<p><strong>MATLAB code for hexadecimal to decimal conversion:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matlabCopyEdit<code>hex_number = 'B4E3';\ndecimal_value = hex2dec(hex_number);\ndisp(decimal_value);  % Output will be 46307\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Decimal to Hexadecimal Conversion (MATLAB Example)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2) Convert the decimal number <code>52705<\/code> into hexadecimal:<\/strong><\/h4>\n\n\n\n<p>To convert a decimal number to hexadecimal, repeatedly divide by 16 and note the remainders.<\/p>\n\n\n\n<p><strong>Step-by-step breakdown:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Divide 52705 by 16: quotient = 3294, remainder = 1.<\/li>\n\n\n\n<li>Divide 3294 by 16: quotient = 206, remainder = 14 (E in hex).<\/li>\n\n\n\n<li>Divide 206 by 16: quotient = 12, remainder = 14 (E in hex).<\/li>\n\n\n\n<li>Divide 12 by 16: quotient = 0, remainder = 12 (C in hex).<\/li>\n<\/ol>\n\n\n\n<p>Reading the remainders from bottom to top gives the hexadecimal representation: <strong>CE1<\/strong>.<\/p>\n\n\n\n<p>Thus, <code>52705<\/code> in decimal is equivalent to <strong>CE1<\/strong> in hexadecimal.<\/p>\n\n\n\n<p><strong>MATLAB code for decimal to hexadecimal conversion:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matlabCopyEdit<code>decimal_number = 52705;\nhex_value = dec2hex(decimal_number);\ndisp(hex_value);  % Output will be 'CE1'\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Explanation<\/strong><\/h3>\n\n\n\n<p>The conversion between number systems is based on the positional value of each digit, where the base of the system determines the power to which the base is raised. In binary, each digit represents a power of 2, while in hexadecimal, each digit represents a power of 16. The conversion processes described above follow these principles: binary and decimal use powers of 2, hexadecimal and decimal use powers of 16 and 10, respectively. MATLAB provides built-in functions <code>bin2dec<\/code>, <code>dec2bin<\/code>, <code>hex2dec<\/code>, and <code>dec2hex<\/code> to perform these conversions automatically, ensuring accuracy and efficiency in calculations.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"1024\" src=\"https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-1543.jpeg\" alt=\"\" class=\"wp-image-44791\" srcset=\"https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-1543.jpeg 852w, https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-1543-250x300.jpeg 250w, https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-1543-768x923.jpeg 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Number conversion using MATLAB between binary and decimal. Show the working steps. 1) Convert the binary number 1010001 into decimal. 2) Convert the decimal number 145 into binary. Number conversion using MATLAB between hexadecimal and decimal. Show the working steps. 1) Convert the hexadecimal number B4E3 into decimal. 2) Convert the decimal number 52705 into [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-44784","post","type-post","status-publish","format-standard","hentry","category-quiz-questions"],"_links":{"self":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/44784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/comments?post=44784"}],"version-history":[{"count":2,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/44784\/revisions"}],"predecessor-version":[{"id":44793,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/44784\/revisions\/44793"}],"wp:attachment":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/media?parent=44784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/categories?post=44784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/tags?post=44784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}