Question
MATLAB HELP! Need help with this homework assignment below: For this homework assignment, you will write a program that will populate a file with an
MATLAB HELP! Need help with this homework assignment below:
For this homework assignment, you will write a program that will populate a file with an NxM matrix, then it will read the NxM matrix in from the file and perform some basic mathematical operations on it (calculate the mode, avg, and find the min, max, and median in the matrix). I ONLY want the algorithms this week.
You must include algorithms/psuedocode for each of your functions (so you should have 6 algorithms). (Algorithms this week).
You should have a main script that is responsible for calling each of the functions necessary to run the program. (Functions and script next week).
Required Functions
populate_matrix this function does not accept any parameters and does not return anything. It should create a 2d matrix (use the randi function) that contains random numbers between 0 and 100. The dimensions should also be generated randomly. Once the matrix is created, it should write the following to a text file:
first line should contain dimensions (row size, followed by a space, followed by column size)
each subsequent line should contain one row of the matrix until the entire matrix has been written to file
process_file this function accepts 1 parameter ( a file name should be the file you created in your populate_matrix function ) and outputs an NxM matrix (dimensions determined by reading the file), plus it should output N and M (which are the row and column size). This function should be able to read in a given file that is correctly formatted, extract all of the numbers in the file and store them as an NxM matrix and return that matrix plus the dimensions of the matrix to the user as return arguments.
calc_mode this function should accept an NxM matrix and it should output the mode of the numbers in the matrix. Do NOT use matlabs built-in function to achieve this. You must code the function yourself
if you dont know what mode is, follow this link: https://www.mathsisfun.com/mode.html
calc_avg this function should accept an NxM matrix and it should output the average of all of the numbers in the matrix. Do NOT use matlabs mean function to do this. You must code this yourself.
find_mmm this function should accept an NxM matrix and output (The output arguments should be in this order) the minimum, maximum, and median values found in the matrix. Do NOT use matlabs built-in functions to do this. You must write the code to do this yourself.
output_results this function should accept the following parameters (in this order): row_count, col_count, mode, average, minimum, maximum, median). This function will print the following items (in this order) in a text file. Each of the items must be on a separate line.
dimensions of matrix: N x M (where N and M are the actual row/column count of matrix)
mode of matrix: (the mode goes here)
average of matrix: (average goes here)
min (minimum value here)
median (median value here)
max (maximum value here)
Deliverables
algorithms for 2 - 6
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started