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 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...
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 a function such that given a number N, display the N*N multiplication matrix from 1...
Write a function such that given a number N, display the N*N multiplication matrix from 1 to N. Then, write a C++ program such that, it prints the multiplication matrices of numbers 1,4,7, and 10 using a loop concept. Check the sample output below, to see how the program should work. Make sure to have your output exactly the same as the below output.
in java Read in a word and display the requested characters from that word in the...
in java Read in a word and display the requested characters from that word in the requested format. Write a Java program that ● prompts the user for a word and reads it, ● converts all characters of the input word to uppercase and display the word with a double quotation mark ( " ) at the start and end of the word, ● displays the word with all characters whose index is odd in lower case and for the...
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT