Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

LO2.2 List the main characteristics of the market system.

Answered: 1 week ago

Question

LO2.5 Describe the mechanics of the circular flow model.

Answered: 1 week ago