// Numbas version: exam_results_page_options {"name": "MATLAB - Matrix creation and basic operations", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "MATLAB - Matrix creation and basic operations", "tags": [], "metadata": {"description": "Part of the tutorial to introduse students to MATLAB programming.", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "
Info:
\nIn Matlab, matrix variable can be created this way m = [row1; row2; row3]
.
For example, variable \\(m\\) containing matrix \\begin{pmatrix}1 & 2 & 3\\\\4 & 5 & 6\\end{pmatrix} can be created by entering following command:
\nm = [1 2 3; 4 5 6]
.
You can multiply two matrices in the same way as numbers: m1*m2
.
Task:
\nIn Matlab, create two variables
\n\\(a=\\var{a}\\)
\nand
\n\\(b=\\var{b}\\)
", "advice": "", "rulesets": {}, "extensions": [], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-5..5),4),3))", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-5..5),3),4))", "description": "", "templateType": "anything"}, "det_ab": {"name": "det_ab", "group": "Ungrouped variables", "definition": "det(ab)", "description": "", "templateType": "anything"}, "transpose_abab": {"name": "transpose_abab", "group": "Ungrouped variables", "definition": "transpose(ab*ab)", "description": "", "templateType": "anything"}, "x": {"name": "x", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-5..5),2),2))", "description": "", "templateType": "anything"}, "y": {"name": "y", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(0..5),2),2))", "description": "", "templateType": "anything"}, "xy": {"name": "xy", "group": "Ungrouped variables", "definition": "x*y", "description": "", "templateType": "anything"}, "xy_pointwise": {"name": "xy_pointwise", "group": "Ungrouped variables", "definition": "matrix([[x[0][0]*y[0][0], x[0][1]*y[0][1]],[x[1][0]*y[1][0], x[1][1]*y[1][1]]])", "description": "", "templateType": "anything"}, "ab": {"name": "ab", "group": "Ungrouped variables", "definition": "a*b", "description": "", "templateType": "anything"}, "ba": {"name": "ba", "group": "Ungrouped variables", "definition": "b*a", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a", "b", "det_ab", "transpose_abab", "x", "y", "xy", "xy_pointwise", "ab", "ba"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Calculate \\(c=ab\\). Note, that you also need to set the correct size for the answer matrix.
", "correctAnswer": "{ab}", "correctAnswerFractions": false, "numRows": 1, "numColumns": 1, "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false}, {"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Calculate \\(d=ba\\). Note, that you also need to set the correct size for the answer matrix.
", "correctAnswer": "{ba}", "correctAnswerFractions": false, "numRows": 1, "numColumns": 1, "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Using the documentation search box in the top right corner find Matlab function for calculating matrix determinant.
\nCompute determinant of the \\(ab\\):
", "minValue": "det_ab", "maxValue": "det_ab", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Search the documentation for a function to transpose a matrix.
\nCalculate transpose of \\(t=(ab)^2\\):
", "correctAnswer": "transpose_abab", "correctAnswerFractions": false, "numRows": 1, "numColumns": 1, "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Create two more matrices in MATLAB:
\n\\(x=\\var{x}\\) and \\(y=\\var{y}\\).
\nCompute following in expressions:
\nx*y
will return [[0]]
x.*y
will return [[1]]
Why results are different?
\n[[2]]
", "gaps": [{"type": "matrix", "useCustomName": true, "customName": "xy", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "correctAnswer": "xy", "correctAnswerFractions": false, "numRows": "2", "numColumns": "2", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false}, {"type": "matrix", "useCustomName": true, "customName": "xy_pointwise", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "correctAnswer": "xy_pointwise", "correctAnswerFractions": false, "numRows": "2", "numColumns": "2", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false}, {"type": "m_n_2", "useCustomName": true, "customName": "x*y vs x.*y", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "minMarks": 0, "maxMarks": 0, "shuffleChoices": true, "displayType": "checkbox", "displayColumns": "1", "minAnswers": "2", "maxAnswers": "2", "warningType": "warn", "showCellAnswerState": true, "choices": ["x*y multiplies matrices", "x.*y multiplies matrices", "x*y multiplies elements of matrices at the same position", "x.*y multiplies elements of matrices at the same position"], "matrix": ["0.5", 0, 0, "0.5"], "distractors": ["", "", "", ""]}], "sortAnswers": false}], "contributors": [{"name": "Timur Zaripov", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3272/"}]}]}], "contributors": [{"name": "Timur Zaripov", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3272/"}]}