// Numbas version: exam_results_page_options
{"name": "MATLAB - creating variables and expression basics", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "MATLAB - creating variables and expression basics", "tags": [], "metadata": {"description": "Part of the tutorial to introduse students to MATLAB programming.
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "
In MATLAB, you can create variables (names for the values) like this: x = 6
.
Now the variable can be used in calculations, for example, y = sin(x)
.
This is how you write some basic maths in MATLAB.
Note the parenthesis around function arguments in MATLAB – you can't skip them.
Task:
Create three variables \\(a = \\var{a}\\), \\(b = \\var{b}\\), \\(c = \\var{c}\\) and calculate the result of the following expressions using MATLAB.
Mathematical expression | \nMATLAB | \n
\\(a\\cdot b\\) | \na*b | \n
\\(\\frac{a}{b}\\) | \na/b | \n
\\(a^b\\) | \na^b | \n
\\(e^a\\) (\\(e\\) here is Euler number) | \nexp(a) | \n
\\(\\sin a\\) | \nsin(a) | \n
\\(\\ln a = \\log_e a\\) (Natural logarithm) | \nlog(a) | \n
\\(d = \\frac{a + b}{c}=\\)
", "minValue": "frac-tol", "maxValue": "frac+tol", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "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": "\\(d = \\frac{a + cos(b)}{c}=\\)
", "minValue": "frac_cos-tol", "maxValue": "frac_cos+tol", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "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": "\\(d = \\sin a + b e^c=\\)
", "minValue": "sin_bec-tol", "maxValue": "sin_bec+tol", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "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/"}]}