// 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": "

Vector creation and basic operations in MATLAB

\n

A vector in MATLAB is just a matrix with one row.

\n

Task:

\n

In MATLAB, create two row vectors

\n

\\(v1=\\var{v1}\\)

\n

and

\n

\\(v2=\\var{v2}\\).

\n

Note, 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:

", "minValue": "dot_v1v2", "maxValue": "dot_v1v2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [{"variables": [{"name": "v1", "value": "vector(0,4,1,6,5,3,8,3)"}, {"name": "v2", "value": "vector(1,-2,0,1,2,0,1,2)"}, {"name": "dot_v1v2", "value": "22"}, {"name": "v3", "value": "vector(0,1,8)"}], "answer": {"valid": true, "value": "x=rand([1 7])", "empty": false}, "notes": [{"name": "regex_match", "expected": {"value": "[ safe(\"x=rand([1 7])\") ]", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "regex_match_case_insensitive", "expected": {"value": "[ safe(\"x=rand([1 7])\") ]", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "exact_match", "expected": {"value": "false", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "exact_match_case_insensitive", "expected": {"value": "false", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "matches", "expected": {"value": "true", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "matches_case_insensitive", "expected": {"value": "true", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "mark", "expected": {"value": "true", "messages": ["Your answer is correct.\n\nYou were awarded 1 mark."], "warnings": [], "error": "", "valid": true, "credit": 1}}, {"name": "interpreted_answer", "expected": {"value": "safe(\"x=rand([1 7])\")", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}]}], "prompt": "

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:

", "answer": ".+=\\s*rand\\(\\s*1\\s*,\\s*7\\s*\\)\\s*|.+=\\s*rand\\(\\[\\s*1\\s+7\\s*\\]\\)\\s*", "displayAnswer": "", "matchMode": "regex"}, {"type": "m_n_x", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

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/"}]}