Question

In: Computer Science

Write a passage and use Mathlab to display a matrix showing the code word and probability...

Write a passage and use Mathlab to display a matrix showing the code word and probability of occurrence of each character. thanks

Solutions

Expert Solution

ANSWER:

I have provided the properly commented code in both text and image format so you can easily copy the code as well as check for correct indentation.
I have provided the output image of the code so you can easily cross-check for the correct output of the code.
Have a nice and healthy day!!

CODE TEXT

% defining paragraph
paragraph = "Write a passage and use Matlab to display a matrix " + ...
    "showing the code word and probability of occurrence of each " + ...
    "character. thanks";

% removing special character from paragraph using function regexpprep in
% matlab
filteredstring = regexprep(paragraph, '[%()\._+-,;:"$]+', '');

% spliting paragraph into words using split function
words = split(filteredstring);

% using function groupcounts to fetch count of each word in array
[counts,group] = groupcounts(words);

% finding probablity of occurenece, by dividing counts by total words
probablity = counts/length(words);

% displaying result
fprintf("Probablity of occurence of %s is %.2f.\n",[group'; probablity']);

CODE IMAGE

OUTPUT IMAGE


Related Solutions

Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and...
Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and results for a 4-bit adder. The inputs are unsigned 4-bit binary numbers. The outcome is a 4-bit binary adder with LED display. First you need to create a symbol for the HEX-to-seven segment display converter. Then implement a 4-bit adder using VHDL. Finally, connect three HEX-to-seven segment display converters to display input X, input Y, and sum S.
Write a program to prompt the user to display the following menu: Sort             Matrix                   Q
Write a program to prompt the user to display the following menu: Sort             Matrix                   Quit If the user selects ‘S’ or ‘s’, then prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side. How many numbers: 6 Original numbers:                     Sorted numbers 34                                                                         2          55                                                      ...
Write a program to prompt the user to display the following menu: Sort             Matrix                   Q
Write a program to prompt the user to display the following menu: Sort             Matrix                   Quit If the user selects ‘S’ or ‘s’, then prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side. How many numbers: 6 Original numbers:                     Sorted numbers 34                                                                         2          55                                                      ...
solution using stack Reversing a word or a sentence: Write an algorithm that will display a...
solution using stack Reversing a word or a sentence: Write an algorithm that will display a given word in a reverse order. - e.g. "Data Structures" will be "serutcurtS ataD".
Write a 200-250 word summary of this passage: The Government’s Position on Illegal Mining             Laws...
Write a 200-250 word summary of this passage: The Government’s Position on Illegal Mining             Laws in South Africa prohibit any one without a license to mine or process gold. However, local authorities lack the manpower needed to properly monitor the thousands of abandoned mine shafts. The South African government is concerned that the large number of “freelance” miners, coupled with a decline in some sectors (e.g. gold) is having a significant negative impact on tax revenues. South Africa’s Chamber...
Write a 200-300 word summary of this passage: The Mining Unions The major mining companies are...
Write a 200-300 word summary of this passage: The Mining Unions The major mining companies are responsible for employing the workers, generating profits and maintaining the mines. When the mines are operational, and in “working condition” or legally open for mining, the National Union of Mineworkers (also known as NUM) organizes all the legally hired mineworkers. NUM has been known to state that low level illegal miners are paying the price for the negative effects of illegal mining while the...
Write the code (in a function) that allows the user to display the first “nb” of...
Write the code (in a function) that allows the user to display the first “nb” of elements in the Fibonacci sequence (each value on a separate line in the console). The order of the Fibonacci sequence goes as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 and on to infinity. Each number is the sum of the previous two (with the 2 starting numbers being 1 and 1). This series of numbers is known as...
How would I write a code from this following word problem? 3. Use the pow() and...
How would I write a code from this following word problem? 3. Use the pow() and sqrt() functions to compute the roots of a quadratic equation. Enter the three coefficients with a single input statement. Warning: if you give sqrt() a negative value, the function cannot produce a valid answer.
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write an algorithm to calculate the recursive Matrix multiplication (or write with pseudo code) 3. Find the time complexity of your pseudo code and analyze the differences
For this C++ program, Write and modify the code to compute and display the class average...
For this C++ program, Write and modify the code to compute and display the class average as well as the standard deviation. Your code changes are as follows: 1. The variable “double grade” should be replaced by a two-dimensional array variable “double grade[NUMSTUDENTS][NUMGRADES].” Also replace the variable “double average” by “double average[NUMSTUDENTS].” This is necessary since you need to save the entered grades specially to compute the standard deviations. 2. After completing the display of the average grade of all...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT