2. Reading and writing spreadsheet files a. Download the file, grades.xlsx, into
ID: 3878414 • Letter: 2
Question
2. Reading and writing spreadsheet files a. Download the file, grades.xlsx, into your Matlab directory. b. Use the xlsread ) function to read the numerical data from the file into an array called scores, and the text data from the file into an array called names Use disp() to display the names to the command window. (Matlab will store the text data in a cell array, which we have not covered yet. We won't ask you to do anything more with it at this point.) Perform the following statistical calculations on the scores and store them in a row vector called grade_stats: mean, median, mode, standard deviation, minimum, maximum. Use help if you are unfamiliar with the Matlab functions to perform these operations c. d. e. Use the xlswrite () function to write the gradestats array to a spreadsheet file called grade stats.x1sx.Explanation / Answer
//this line of code prints the names column from the excelsheet which im considering is the first column i.e. A
names=xlsread('grades.xlsx','A:A');
//this line of code prints the scores column from the excelsheet which im considering is the first column i.e. B
scores=xlsread('grades.xlsx','B:B');
//this line of code prints the names array in the command window
disp(names);
//inbuilt function to calculate minimum
minimum = min(scores(:));
//inbuilt function to calculate maximum
maximum = max(scores(:));
//inbuilt function to calculate mean
meanVal = mean(scores(:));
//inbuilt function to calculate standard deviation
standardDeviation = std(scores(:));
//inbuilt function to calculate median
medianVal = median(scores(:));
//inbuilt function to calculate mode
modeVal = mode(scores(:));
//creating the array of headers to be written into the xlsx file
header = ['Mean','Median','Mode','Standard Deviation','Minimum','Maximum'];
//creating the array of values to be written into the xlsx file
values = [meanVal,medianVal,modeVal,standardDeviation,minimum,maximum];
//this line of code writes to the file grade_stats.xlsx
xlswrite('grade_stats.xlsx',{header;values});
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.