Complete the code to display the text 'Hello, MATLAB!' in the Command Window.
disp([1]);The disp function displays text in the Command Window. The text must be enclosed in single quotes to be treated as a string.
Complete the code to assign the value 10 to a variable named 'x' in the Command Window.
[1] = 10;
In MATLAB, you assign values to variables using the equals sign. Here, x is the variable name.
Fix the error in the code to correctly clear the variable 'data' from the workspace.
clear [1];The clear command removes variables by name without quotes. Using quotes causes an error.
Fill both blanks to create a 1-by-5 vector named 'v' with values from 1 to 5 and display it.
[1] = [2]; disp(v);
zeros or ones instead of the range.We assign the vector 1:5 to variable v. The disp function then shows it.
Fill all three blanks to create a script that prompts the user for their name, stores it in 'userName', and then greets them.
userName = [1]('Enter your name: ', '[2]'); fprintf('Hello, %[3]s!\n', userName);
input.fprintf.The input function asks the user for input. The second argument 's' tells MATLAB to treat input as a string. The fprintf uses %s to print the string.