// Numbas version: exam_results_page_options {"name": "MATLAB - vector creation", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "MATLAB - vector creation", "tags": [], "metadata": {"description": "Part of the tutorial to introduse students to MATLAB programming.", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

MATLAB: range vector creation

\n

Often we want to have a vector comprised of values in the range between two numbers xmin and xmax. We can do this in two ways.

Tasks:

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"xmin": {"name": "xmin", "group": "Ungrouped variables", "definition": "dec(random(1..6)/10)", "description": "", "templateType": "anything"}, "xmax": {"name": "xmax", "group": "Ungrouped variables", "definition": "dec(random(50..100)/10)", "description": "", "templateType": "anything"}, "xstep": {"name": "xstep", "group": "Ungrouped variables", "definition": "dec(random(1..10)/1000)", "description": "", "templateType": "anything"}, "nsteps": {"name": "nsteps", "group": "Ungrouped variables", "definition": "random(20..100)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["xmin", "xmax", "xstep", "nsteps"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "patternmatch", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [{"variables": [{"name": "xmin", "value": "0.2"}, {"name": "xmax", "value": "6.4"}, {"name": "xstep", "value": "0.01"}, {"name": "nsteps", "value": "82"}], "answer": {"valid": true, "value": "x = [0.2:0.01: 6.4]", "empty": false}, "notes": [{"name": "regex_match", "expected": {"value": "[ safe(\"x = [0.2:0.01: 6.4]\") ]", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "regex_match_case_insensitive", "expected": {"value": "[ safe(\"x = [0.2:0.01: 6.4]\") ]", "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 = [0.2:0.01: 6.4]\")", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}]}], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

If we want to values separated by a certain step xstep, the : (colon) the operator inside square brackets is used like this: x = [xmin:xstep:xmax].

\n

Create vector \\(x\\) of values from {xmin} to {xmax} with the step {xstep}. Below enter the command you used:

", "answer": ".+=\\s*\\[\\s*{xmin}\\s*:\\s*{xstep}\\s*:\\s*{xmax}\\s*\\]\\s*", "displayAnswer": "", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [{"variables": [{"name": "xmin", "value": "0.2"}, {"name": "xmax", "value": "7.1"}, {"name": "xstep", "value": "0.002"}, {"name": "nsteps", "value": "70"}], "answer": {"valid": true, "value": "x = linspace(0.2,7.1,70)", "empty": false}, "notes": [{"name": "regex_match", "expected": {"value": "[ safe(\"x = linspace(0.2,7.1,70)\") ]", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "regex_match_case_insensitive", "expected": {"value": "[ safe(\"x = linspace(0.2,7.1,70)\") ]", "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 = linspace(0.2,7.1,70)\")", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}]}], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

If we don't know the step but want to create an interval with exactly \\(n\\) points, the linspace command is used. Look up this command in the documentation for the description and examples of use.

\n

Create vector \\(x\\) of values from {xmin} to {xmax} with {nsteps} points. Below enter the command you used:

", "answer": ".+=\\s*linspace\\(\\s*{xmin}\\s*,\\s*{xmax}\\s*,\\s*{nsteps}\\s*\\)\\s*", "displayAnswer": "", "matchMode": "regex"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "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/"}]}