Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a variable named x with the value 10.
MATLAB
x = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number in quotes, which creates a string instead of a number.
Using the variable name on the right side instead of a value.
✗ Incorrect
The variable
x is assigned the numeric value 10 using x = 10;.2fill in blank
mediumComplete the code to clear the variable y from the workspace.
MATLAB
clear [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
clear without specifying the variable name clears all variables.Typing the command incorrectly, like
clear workspace.✗ Incorrect
The command
clear y; removes the variable y from the workspace.3fill in blank
hardFix the error in the code to list all variables currently in the workspace.
MATLAB
vars = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
who() with parentheses, which is incorrect syntax in MATLAB.Using non-existent commands like
listvars or variables.✗ Incorrect
The
whos command lists detailed information about variables in the workspace.4fill in blank
hardFill both blanks to save variables a and b to a file named data.mat.
MATLAB
save('[1]', [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting variable names in quotes as a single string.
Not quoting the filename.
Separating variable names with commas.
✗ Incorrect
The
save command saves variables a and b to the file data.mat. Variable names are listed without quotes separated by spaces.5fill in blank
hardFill all three blanks to load variables m and n from the file mydata.mat into the workspace.
MATLAB
load('[1]', '[2]', '[3]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the filename or variable names.
Using the wrong filename.
Listing variables without quotes.
✗ Incorrect
The
load command loads variables m and n from the file mydata.mat. The filename and variable names are all strings in quotes.