Define a function named tokens_to_str_code that accepts à matrix and a scalar value representing a time_unit. The token matrix has 2 columns and multiple rows. Each row 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, 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
Define a function named tokens_to_str_code that accepts à matrix and a scalar value representing a time_unit. The token matrix has 2 columns and multiple rows. Each row 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, 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
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
100%
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F39d48593-4bc5-46a1-a9ce-661c683f5af7%2F06abfb17-a1e4-431a-a2fc-6e68f26632d6%2F5i90shf_processed.png&w=3840&q=75)
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
![function result =
result = '';
1
tokens_to_str_code(token_mat, time_unit)
3
for i =1:size(token_mat,1)
4
5 if(token_mat (i,1)
if(token_mat(i,2) > 4*time_unit)
result = strcat(result,"-");
elseif((token_mat(i,2) > time_unit) && (token_mat(i,2) < 4*time_unit))
1)
==
7
9
result =
strcat(result,".");
10
end
elseif(token_mat(i,1)
if(token_mat(i,2) > 8*time_unit)
result = strcat(result,"/");
elseif((token_mat(i,2)
11
== 0)
12
13
14
4*time_unit) && (token_mat(i,2) < 8*time_unit))
15
result
strcat(result," ");
%3D
16
end
17
end
18
end
19
end
20
21
Check
Test
Expected
Got
tokens %3D [1 4; е 3; 1 3; е 1; 1 3; е 1; 1 1; ө 1; 1 1 ];
time_unit = .5;
disp( tokens_to_str_code( tokens, time_unit ))
tokens = [ 0 4; 1 1457; 0 463; 1 1457; 0 463; 1 497; 0 1423; 1 1457;
---/..--..
--.---/..--..
о 463; 1 1457; 0 463; 1 1457; ө 3343; 1 497; ө 463; 1 497; 0 463;
1 1457; 0 1423; 1 1457; 0 463; 1 497; 0 463; 1 497; e 379 ];
time_unit
= 240;
disp( tokens_to_str_code( tokens, time_unit ))](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F39d48593-4bc5-46a1-a9ce-661c683f5af7%2F06abfb17-a1e4-431a-a2fc-6e68f26632d6%2Fj3rvaan_processed.png&w=3840&q=75)
Transcribed Image Text:function result =
result = '';
1
tokens_to_str_code(token_mat, time_unit)
3
for i =1:size(token_mat,1)
4
5 if(token_mat (i,1)
if(token_mat(i,2) > 4*time_unit)
result = strcat(result,"-");
elseif((token_mat(i,2) > time_unit) && (token_mat(i,2) < 4*time_unit))
1)
==
7
9
result =
strcat(result,".");
10
end
elseif(token_mat(i,1)
if(token_mat(i,2) > 8*time_unit)
result = strcat(result,"/");
elseif((token_mat(i,2)
11
== 0)
12
13
14
4*time_unit) && (token_mat(i,2) < 8*time_unit))
15
result
strcat(result," ");
%3D
16
end
17
end
18
end
19
end
20
21
Check
Test
Expected
Got
tokens %3D [1 4; е 3; 1 3; е 1; 1 3; е 1; 1 1; ө 1; 1 1 ];
time_unit = .5;
disp( tokens_to_str_code( tokens, time_unit ))
tokens = [ 0 4; 1 1457; 0 463; 1 1457; 0 463; 1 497; 0 1423; 1 1457;
---/..--..
--.---/..--..
о 463; 1 1457; 0 463; 1 1457; ө 3343; 1 497; ө 463; 1 497; 0 463;
1 1457; 0 1423; 1 1457; 0 463; 1 497; 0 463; 1 497; e 379 ];
time_unit
= 240;
disp( tokens_to_str_code( tokens, time_unit ))
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY