Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a logical true value.
MATLAB
x = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric 1 instead of logical true
Using false or 0 which represent logical false
✗ Incorrect
In MATLAB, true is the logical value for true.
2fill in blank
mediumComplete the code to check if variable a is greater than 5.
MATLAB
result = (a [1] 5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Using == which checks equality
✗ Incorrect
The operator > checks if a is greater than 5, returning a logical value.
3fill in blank
hardFix the error in the code to correctly assign a logical false value.
MATLAB
flag = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized False which is invalid
Using 0 which is numeric, not logical false
✗ Incorrect
MATLAB uses lowercase false to represent logical false.
4fill in blank
hardFill both blanks to create a logical array with true and false values.
MATLAB
arr = [[1], [2]];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric 1 and 0 instead of logical true and false
Mixing uppercase and lowercase keywords
✗ Incorrect
The array contains logical true and false values.
5fill in blank
hardFill all three blanks to create a logical vector where elements are true if x is greater than 3, less than 7, and not equal to 5.
MATLAB
result = (x [1] 3) & (x [2] 7) & (x [3] 5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of ~=
Mixing up > and < operators
✗ Incorrect
The expression checks if x is greater than 3, less than 7, and not equal to 5, returning logical values.