![matlab grader matlab grader](https://www.mathworks.com/help/matlabgrader/ug/list_view.png)
RightWrong = datasetfun(f,alldata, 'DatasetOutput',true. I make an effort to label the rows with the students' names here. Use datasetfun by comparing all elements in a column for students (i.e., 2:end) with first element of that column, the rightĪnswer. So I can compare their answers to the truth (row 1).į = 100*sum(x(1)=x(2:end))/(size(alldata,1)-1)
![matlab grader matlab grader](https://media.cheggcdn.com/media/197/197626fb-9396-4eb1-9e3a-494028d7efaf/phpTha9cC.png)
First I need to find out which questions students got right and wrong I can use the datasetfun function, similar to cellfun and arrayfun, to apply a function to each variable in the data. Suppose I want to find out which questions are hardest for this set of students. Whos q4* Name Size Bytes Class AttributesĪnd I can also find out all answers for one student, resulting in another dataset array.ĬhrisAnswers = alldata( 'Chris',:) ChrisAnswers = I get a nominal vector in return here since the Q4 column contains the answers to a multiple choice question. I can get all the students' answers to a particular question. To get a single answer, I have another option. The questions have extraordinarily imaginative names. I have an assignment with 5 questions, 2 T/F and 3 multiple choice (a:d). Showing here, grading an assignment, shows some of the simpler ways in which you might use a dataset array. The collections are more constrained (in this case, 1:1) than the flexibility afforded by cells or structs. You might want to use a dataset array if the data you have is natural to think of as collection of different but related entities. Additionally, a dataset array can have labels that allow you to reference data not just by numeric or logical indexing, but by names as well. To have names with a cell array, you either need to carry around an extra array, or have a special row or column to containĪ scalar structure similarly can perform this service but but does not enforce the idea that each field must hold the same Together may comprise many different data types.Ī cell array can do this, but does not enforce the idea that all the elements in a given column must have the same type. A dataset array is basically two-dimensional array where each column holds data represented in a single data type, but the columns