Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function ret=excel_columnaverage(filename,column) that takes an Excel fi

ID: 3558030 • Letter: W

Question

Write a function ret=excel_columnaverage(filename,column) that takes an Excel file's name, and a column id (or name) and returns the average of the numbers in that column. If column is a number, it directly denotes the column number. If column is a string, you need to find a case-insensitive match in the first header row to determine the column number. When taking the average of the values in a column, any entry not containing a number should be ignored.

Hints: Matlab's xlsread() function returns three output arguments: num,txt,raw. It is best to use raw output to solve this problem. If the input column variable is a string, use the first row of raw to find the column number. Once you identify the column number, extract the requested column into a vector rawvector. Write a for loop that goes over each element of the rawvector and collects the entries containing a valid number into a vector v . Only consider entries that contain a number (isnumeric()), and are not NaN (isnan()). After the loop, you can calculate the average of the numbers accumulated in v .

Explanation / Answer

Syntax

Description

example

num = xlsread(filename) reads data from the first worksheet in the Microsoft

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote