Answered step by step
Verified Expert Solution
Question
1 Approved Answer
these problems are for matlab Problem 3 Write a program that prompts the user for a string of unspecified length made up of characters and
these problems are for matlab
Problem 3 Write a program that prompts the user for a string of unspecified length made up of characters and 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 (hint: one way to do this is by building your output vector of binary digits using a switch statement nested within a for loop). You may assume valid user input. Use the following key for your translations: Character 1 "A" or "a" "B" or "b "C" or "c" "D" or "d" "E" or "e "F" or "F" "Gorg "H" or "h" "" or "j" "J" or " "K" or "k Lory "M" or "m" "N" or "n" "O" or "o "P" or "p" Code 00000 00001 100010 100011 | 00100 100 101 00110 1 00111 01000 01001 101010 | 01011 01100 | 01101 01110 01111 Character 10" or " "R" or " "S" or " "Tor " | 'U' or 'u" | "V" or "v" W or w X" or " "Y" or "y" 1 Zorz NRRERERGER Code 10000 10001 10010 10011 101001 101011 10110 10111 11000 11001 11010 11011 11100 | 11101 11110 | 11111 Example of how program works: Prompt user for input User inputs: 'HelloWorld! Create a string vector for binary output (output = '';) Start loop Determine first character (H) Set binary output vector to '00111' (output = strcat(output,'00111'):) Restart loop Determine second character "e", same result as "E") Append '00100' to the end of the output vector (output = strcat (output,'00100):) End loop after all characters are read Display the output vector of binary digits Problem 5 The first harmonic included in the Fourier series for a zero-centered triangle wave of period 1 and peak 1 is as follows: f (t) = (-1)^(1)->sin (2 (1)t) The next included harmonic is: f(t) = (1-1)+(3)-2sin (27(35) And then the following harmonic is: fa(t) = ((-1)2(5)-2sin (21(5)t) And so on. Use a while loop to calculate the sum of the first N harmonics in this Fourier series, where N is a user-specified integer greater than 1, and then plot this function. Make sure your code rejects invalid user input for N. Use the following line of code to set up the time vector: t = linspace(0,2,1200)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started