0
0
MATLABdata~10 mins

MATLAB Desktop and Command Window - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to display the text 'Hello, MATLAB!' in the Command Window.

MATLAB
disp([1]);
Drag options to blanks, or click blank then click option'
A'Hello, MATLAB!'
BHello, MATLAB!
C"Hello, MATLAB!"
Ddisp('Hello, MATLAB!')
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the text.
Using double quotes instead of single quotes in older MATLAB versions.
2fill in blank
medium

Complete the code to assign the value 10 to a variable named 'x' in the Command Window.

MATLAB
[1] = 10;
Drag options to blanks, or click blank then click option'
Avalue
Bvar
Cx
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number as a variable name.
Putting the value on the left side.
3fill in blank
hard

Fix the error in the code to correctly clear the variable 'data' from the workspace.

MATLAB
clear [1];
Drag options to blanks, or click blank then click option'
Adata
B'data'
C"data"
Dclear data
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name.
Typing the whole command inside the blank.
4fill in blank
hard

Fill both blanks to create a 1-by-5 vector named 'v' with values from 1 to 5 and display it.

MATLAB
[1] = [2]; disp(v);
Drag options to blanks, or click blank then click option'
Av
B1:5
Czeros
Dones
Attempts:
3 left
💡 Hint
Common Mistakes
Using zeros or ones instead of the range.
Not assigning to a variable.
5fill in blank
hard

Fill all three blanks to create a script that prompts the user for their name, stores it in 'userName', and then greets them.

MATLAB
userName = [1]('Enter your name: ', '[2]'); fprintf('Hello, %[3]s!\n', userName);
Drag options to blanks, or click blank then click option'
Ainput
B's'
Cformat
D'string'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the 's' argument in input.
Using wrong format specifier in fprintf.