Question

In: Computer Science

In very simple cryptograph, the intended message sometimes consists of the first letterof very word in...

In very simple cryptograph, the intended message sometimes consists of the first letterof very word in upper case in a string. Write a function cryptmessage that will receive a string or a character vector with the message and return the encrypted message.

>>messagestring=' the Early songbird tweets ';

>>m=cryptmessage(messagestring)

m=' TEST'

Please put it in MATLAB

Solutions

Expert Solution

The code for solving the above problem is as follows:

function result = cryptmessage(input_string)
    result = '';
    x = strsplit(strtrim(input_string));
    for i=1:length(x)
       data = string(x(i));
       result = append(result, data{1}(1));
    end
    result = upper(result);
end

An initial empty string result is initialised to store the result of the cryptanalysis. Then, the leading and trailing whitespaces are removed using the strtrim function, and then split into the constituent words using the strsplit function. Then, iterating over the elements of the array of split words, the data is converted into a string from the cell array (since strsplit returns a cell array), and the first character of that string is selected using the indexing method of data{1}(1). This indexed first character is then added to the result string. Finally, the result string is converted into uppercase using the upper function.  

The output is as shown below:

A screenshot of the code:

(If you liked the answer, feel free to give it a thumbs up. Thank you so much!)


Related Solutions

Two different simple random samples are drawn from two different populations. The first sample consists of...
Two different simple random samples are drawn from two different populations. The first sample consists of 20 people with 9 having a common attribute. The second sample consists of 2000 people with 1440 of them having the same common attribute. Compare the results from a hypothesis test of p 1equalsp 2 ​(with a 0.01 significance​ level) and a 99​% confidence interval estimate of p 1minusp 2. Identify the test statistic. Identify the critical​ value(s).
Two different simple random samples are drawn from two different populations. The first sample consists of...
Two different simple random samples are drawn from two different populations. The first sample consists of 40 people with 19 having a common attribute. The second sample consists of 2200 people with 1555 of them having the same common attribute. Compare the results from a hypothesis test of p 1=p 2 ​(with a 0.01 significance​ level) and a 99​% confidence interval estimate of p 1-p 2. Calculate the test statistic z to two decimal places, the critical values, and find...
Two different simple random samples are drawn from two different populations. The first sample consists of...
Two different simple random samples are drawn from two different populations. The first sample consists of 30 people with 14 having a common attribute. The second sample consists of 1900 people with 1370 of them having the same common attribute. Compare the results from a hypothesis test of p 1equalsp 2 ​(with a 0.01 significance​ level) and a 99​% confidence interval estimate of p 1minusp 2. What are the null and alternative hypotheses for the hypothesis​ test? A. Upper H...
Which of the following is an example of ways in which the word “assurance” is sometimes...
Which of the following is an example of ways in which the word “assurance” is sometimes used? A. Actions taken to provide a basis for justified confidence – these actions may constitute how something is done, or the evaluations of something or how it is/was done; B. Arguments and evidence that reduce uncertainty or provide grounds to justify confidence C. Degree an individual or organization has of justified confidence in something such as the justifiable confidence that a system exhibits...
How does style and word choice in this speech impact the effectiveness of the message?
How does style and word choice in this speech impact the effectiveness of the message?
In accounting does the LIFO method change. Sometimes it means the oldest is first, sometimes it...
In accounting does the LIFO method change. Sometimes it means the oldest is first, sometimes it means the most recent?
10. Two different simple random samples are drawn from two different populations. The first sample consists...
10. Two different simple random samples are drawn from two different populations. The first sample consists of 40 people with 21 having a common attribute. The second sample consists of 1800 people with 1271 of them having the same common attribute. Compare the results from a hypothesis test of p 1=p  2 ​(with a 0.05 significance​ level) and a 95​% confidence interval estimate of p 1-p 2. What are the null and alternative hypotheses for the hypothesis​ test? A.H 0​: p...
Create a very simple temperature converter form having two text fields. The first one is where...
Create a very simple temperature converter form having two text fields. The first one is where the user will enter temperature. The second field is where the computed temperature value is displayed depending on the unit (F or C).use html and javascript
A message consists of 8,000,000 bytes. The sender’s network adapter can transmit at a rate of...
A message consists of 8,000,000 bytes. The sender’s network adapter can transmit at a rate of 100,000 bytes per a second. The receiver’s network adapter can receive 40,000 bytes per second.   It takes 20 ms for data to move across the network.   Assuming no data is lost on the way, how long does it take for the message to read in by the receiver?
Using Microsoft Word, create an email message to your boss that: Summarizes the requirements of the...
Using Microsoft Word, create an email message to your boss that: Summarizes the requirements of the CAPSIM Business Simulation project and describes how you will approach the project. Summarizes the requirements of the Capstone project and describes how you will approach that project. Your email should be formatted according to the guidelines. Your document should contain two paragraphs and be no longer than one page.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT