Solve the following problems in a MATLAB script. (Please give all the solutions
ID: 1716884 • Letter: S
Question
Solve the following problems in a MATLAB script.
(Please give all the solutions and steps. Please don't answer the question if you can't do all the questions, THANKS)
P3: When working with computer, microprocessors or digital systems most of the commands are represented in binary numbers, hexadecimal numbers, ASCII or octal. We want to write a code that do the following a. Inputs are decimal digits from 150 to 250 counting by 5 b. When the counter find a number smaller than 200 the result will be the same number converted into hexadecimal c. When the counter find an number bigger than 200 the result will be the same number converted into binary d. When the counter find 200 display "We are at the 200 from now on the numbers will be display as binary numbers"Explanation / Answer
%INPUT DECIMAL DIGITS ARE COUNTING BY 5
for counter=150:5:250
%IF THE COUNTER IS LESS THAN 200 THEN THAT NUMBER PRINTED AS HEXADECIMAL FORMAT
if (counter<200)
fprintf('%d Hexadecimal equivalnet %s ',counter,dec2hex(counter));
%IF THE COUNTER IS GREATER THAN 200 THEN THAT NUMBER PRINTED AS BINARY FORMAT
elseif (counter>200)
fprintf('%d Binary equivalnet %s ',counter,dec2bin(counter));
%IF NUMBER EQUAL TO 200 THEN FOLLOWING IS DISPLAYED
else
fprintf('We are at the 200 from now on the numbers will be display as binary numbers ');
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.