Algorithm: Initialize empty string to keep track of Morse code string code Loop over token matrix Check current token(0 or 1) If 1, Check if token duration is greater than 4*duration, if true concatenate dash to string Check if token duration is greater than 4, but less than 4*duration, if true concatenate a dot If 0, Check if token is greater than 8*duration, if true, concatenate slash Check if token is greater than 4*duration and less than 8*duration, if true concatenate a space to string   Check next token Return string to get the string code

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Algorithm:

Initialize empty string to keep track of Morse code string code

Loop over token matrix

Check current token(0 or 1)

If 1,

Check if token duration is greater than 4*duration, if true concatenate dash to string

Check if token duration is greater than 4, but less than 4*duration, if true concatenate a dot

If 0,

Check if token is greater than 8*duration, if true, concatenate slash

Check if token is greater than 4*duration and less than 8*duration, if true concatenate a space to string

 

Check next token

Return string to get the string code

Define a function named tokens_to_str_code that accepts a matrix and a scalar value representing a time_unit. The token matrix has 2 columns and multiple rows. Each row represents either
a dot, dash, a short space, a long space or a long-long space. This function uses the rules in the table below to map the token information for one row to either a dot, a dash, a forward slash
or a blank space.
You can use these tests to debug your function in MATLAB or Octave:
Token Matrix
String Code
Column One
Column Two
Converts to:
(Token Value)
(Token Duration)
1
greater than 4 * time_unit
- (dash)
greater than or equal to time_unit
1
(dot)
but less or equal to 4 * time_unit
greater than or equal to 8 * time_unit
(space between a word)
greater than or equal to 4 * time_unit
space (space between characters)
but less than or equal to 8* time_unit
everything else can be ignored – doesn't represent anything
Transcribed Image Text:Define a function named tokens_to_str_code that accepts a matrix and a scalar value representing a time_unit. The token matrix has 2 columns and multiple rows. Each row represents either a dot, dash, a short space, a long space or a long-long space. This function uses the rules in the table below to map the token information for one row to either a dot, a dash, a forward slash or a blank space. You can use these tests to debug your function in MATLAB or Octave: Token Matrix String Code Column One Column Two Converts to: (Token Value) (Token Duration) 1 greater than 4 * time_unit - (dash) greater than or equal to time_unit 1 (dot) but less or equal to 4 * time_unit greater than or equal to 8 * time_unit (space between a word) greater than or equal to 4 * time_unit space (space between characters) but less than or equal to 8* time_unit everything else can be ignored – doesn't represent anything
Test
Result
token_mat =
[1 5; 1 6; 1 5; 17; 0 20; 1 5; 1 5; 0 40;
1 5; 1 20; 1 6; 1 5; 0 21; 119; 1 20; 1 20; ];
./.-..
time_unit = 4;
disp (tokens_to_str_code(token_mat, time_unit))
Transcribed Image Text:Test Result token_mat = [1 5; 1 6; 1 5; 17; 0 20; 1 5; 1 5; 0 40; 1 5; 1 20; 1 6; 1 5; 0 21; 119; 1 20; 1 20; ]; ./.-.. time_unit = 4; disp (tokens_to_str_code(token_mat, time_unit))
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education