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

MATLAB: Basic plotting

The basic command to produce plots is plot. Find documentation for it using the documentation search box in the top right corner of MATLAB window. Use the documentation to complete the following tasks.

Note, that in MATLAB every new plot command overwrites previous plots. If you want to keep old plots, use figure command to create a new plot window. If you want to plot a new line in the existing graph use hold on command. Look up these commands in the documentation for more details.

Task:

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"xmin": {"name": "xmin", "group": "Ungrouped variables", "definition": "dec(random(0..10)/100)", "description": "", "templateType": "anything"}, "xmax": {"name": "xmax", "group": "Ungrouped variables", "definition": "dec(random(10..100)/10)", "description": "", "templateType": "anything"}, "xstep": {"name": "xstep", "group": "Ungrouped variables", "definition": "dec(random(0..10)/1000)", "description": "", "templateType": "anything"}, "colour": {"name": "colour", "group": "Ungrouped variables", "definition": "[\"red\", \"green\", \"blue\", \"black\"]", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["xmin", "xmax", "xstep", "colour"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "patternmatch", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Create vector \\(x\\) of values from {xmin} to {xmax} with step {xstep}. Calculate \\(y=\\sin x\\) and plot \\(y\\) against \\(x\\).

\n

Enter the plot command you used:

", "answer": "plot\\(\\s*x\\s*,\\s*y.*\\)\\s*|plot\\(\\s*x\\s*,\\s*sin\\(x\\)s*\\)\\s*", "displayAnswer": "", "matchMode": "regex"}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Create a new plot window and one by one add the following graphs. To distinguish between lines use lookup LineSpec in the documentation.

\n

\\(\\sin x\\) on interval of values from {xmin} to {xmax} with step {xstep} as a {colour[0]} line.
LineSpec for {colour[0]}: [[0]]

\\(\\cos x\\) on interval of values from {xmin} to {xmax} with step {xstep} as a {colour[1]} line.
LineSpec for {colour[1]}: [[1]]

\\(e^x\\) on interval of values from {xmin} to {xmax} with step {xstep} as a {colour[2]} line.
LineSpec for {colour[2]}: [[2]]

\\(\\ln x\\) on interval of values from {xmin} to {xmax} with step {xstep} as a {colour[3]} line.
LineSpec for {colour[3]}: [[3]]

", "gaps": [{"type": "patternmatch", "useCustomName": true, "customName": "r", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "'r'", "displayAnswer": "", "matchMode": "exact"}, {"type": "patternmatch", "useCustomName": true, "customName": "g", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "'g'", "displayAnswer": "", "matchMode": "exact"}, {"type": "patternmatch", "useCustomName": true, "customName": "b", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "'b'", "displayAnswer": "", "matchMode": "exact"}, {"type": "patternmatch", "useCustomName": true, "customName": "k", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "'k'", "displayAnswer": "", "matchMode": "exact"}], "sortAnswers": false}], "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/"}]}