Question: Matlab Problem 2 Write a program that first prompts the user for a string of unspecified length made up of characters and that then translates
Matlab


Problem 2 Write a program that first prompts the user for a string of unspecified length made up of characters and that then translates this string into a sequence of binary digits. You will do this by translating each character of the input string into a vector of five binary digits and then appending these vectors successively to one long vector that represents the whole message. Use the following key for your translations (you can assume valid user input): Character Code "A" or "a" 00000 "B" or "b" | 00001 "C" or "c 00010 "D" or "d" 00011 "E" or "e | 00100 "F" or "f 00101 "G" or "" 00110 "H" or "h" | 001 1 1 " or " "J" or "01001 "K" or "k" | 01010 L" or "l" | 01 01 1 M" or "m" | 01 100 "N" or "n" 01101 "O" or "o | 01110 "P" or "" 01111 Character Code "Q" or "q" 10000 "R" or "r" 10001 "S" or "s"10010 10011 "U" or "u" 10100 " or "" 10101 W" or " 10110 "X" or "x" | 10111 11000 "Z" or "Z"11001 11010 11011 11100 11101 "T" or "t" 01000 "Y" or Example of how the program works: -Code prompts user for input -User inputs: Helloworld! -Code creates an empty character output':) -Code enters loop -Code determines first character ("H") -Code sets output vector to "O01 11" (output strcat(output,'00111');) -Loop repeats -Code determine second character ("e"; same result as "E") -Code appends "00100" to the end of the output vector (output vector for binary output strcat (output, '00100');) -Loop ends after all characters are read
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
