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...
icon
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
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 ))
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
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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…
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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY