// Numbas version: exam_results_page_options {"name": "MATLAB - Row vs column, rand", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "MATLAB - Row vs column, rand", "tags": [], "metadata": {"description": "Part of the tutorial to introduse students to MATLAB programming.", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "
A vector in MATLAB is just a matrix with one row.
\nTask:
\nIn MATLAB, create two row vectors
\n\\(v1=\\var{v1}\\)
\nand
\n\\(v2=\\var{v2}\\).
\nNote, that in mathematical notation the vectors are written as columns. In MATLAB you need to produce row vectors.
", "advice": "", "rulesets": {}, "extensions": [], "variables": {"v1": {"name": "v1", "group": "Ungrouped variables", "definition": "vector(repeat(random(0..9), 8))", "description": "", "templateType": "anything"}, "v2": {"name": "v2", "group": "Ungrouped variables", "definition": "vector(repeat(random(-4..4), 8))", "description": "", "templateType": "anything"}, "dot_v1v2": {"name": "dot_v1v2", "group": "Ungrouped variables", "definition": "dot(v1, v2)", "description": "", "templateType": "anything"}, "v3": {"name": "v3", "group": "Ungrouped variables", "definition": "vector(repeat(random(0..9), 3))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["v1", "v2", "dot_v1v2", "v3"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "Calculate the dot product of \\(v1\\) and \\(v2\\). Note, that dot product is not the same thing as v1*v2
, you can find this function in the documentation. Enter result below:
Search the documentation for the rand
function that is used to create random vectors and matrices. Use it to create a row vector \\(vrand\\) of 7 elements (1x7 matrix). Enter the command you used below:
Create another vector \\(v3=\\var{v3}\\).
", "minMarks": 0, "maxMarks": 0, "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": true, "shuffleAnswers": true, "displayType": "radiogroup", "warningType": "none", "showCellAnswerState": true, "choices": ["v1*v2
", "v1.*v2
", "v2.*v3
"], "matrix": [["1", 0, 0], [0, 0, "1"], [0, "1", 0]], "layout": {"type": "all", "expression": ""}, "answers": ["Error: Incorrect dimensions for matrix multiplication.", "Error: Matrix dimensions must agree.", "Result is a vector."]}], "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/"}]}